logger

package module
v0.0.0-...-fbe71e7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2017 License: MIT Imports: 3 Imported by: 3 modules, 4 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

logger

A simple log library

License ReportCard GoDoc

Get

go get github.com/LyricTian/logger

Usage

package main

import (
	"github.com/LyricTian/logger"
)

func main() {
	log := logger.NewStdLogger(true, true, true, true, logger.TimeFlag)
	log.Debugf("hello,%s", "world")
	log.Tracef("hello,%s", "world")
	log.Infof("hello,%s", "world")
	log.Errorf("hello,%s", "world")
	log.Fatalf("hello,%s", "world")
}

Features

  • Based on the standard library log
  • Support output to the console and file

MIT License

Copyright (c) 2017 LyricTian

Documentation

Index

Constants

View Source
const (
	TimeFlag     = log.LstdFlags | log.Lmicroseconds
	FileFlag     = log.Lshortfile
	TimeFileFlag = TimeFlag | FileFlag
)

Defines the log format

Variables

This section is empty.

Functions

func Debugf

func Debugf(format string, v ...interface{})

Debugf logs a debug statement

func Errorf

func Errorf(format string, v ...interface{})

Errorf logs an error statement

func Fatalf

func Fatalf(format string, v ...interface{})

Fatalf logs a fatal error

func Infof

func Infof(format string, v ...interface{})

Infof logs a notice statement

func SetLogger

func SetLogger(logger *Logger)

SetLogger specify one Logger

func Tracef

func Tracef(format string, v ...interface{})

Tracef logs a trace statement

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger A Logger represents an active logging object that generates lines of output to an io.Writer.

func NewFileLogger

func NewFileLogger(filename string, debug, trace, pid bool, flag int) *Logger

NewFileLogger creates a logger with output directed to a file

func NewStdLogger

func NewStdLogger(debug, trace, colors, pid bool, flag int) *Logger

NewStdLogger creates a logger with output directed to Stderr

func (*Logger) Debugf

func (l *Logger) Debugf(format string, v ...interface{})

Debugf logs a debug statement

func (*Logger) Errorf

func (l *Logger) Errorf(format string, v ...interface{})

Errorf logs an error statement

func (*Logger) Fatalf

func (l *Logger) Fatalf(format string, v ...interface{})

Fatalf logs a fatal error

func (*Logger) Infof

func (l *Logger) Infof(format string, v ...interface{})

Infof logs a notice statement

func (*Logger) Printf

func (l *Logger) Printf(format string, v ...interface{})

Printf print to the logger

func (*Logger) SetCallDepth

func (l *Logger) SetCallDepth(calldepth int)

SetCallDepth set call depth

func (*Logger) Tracef

func (l *Logger) Tracef(format string, v ...interface{})

Tracef logs a trace statement

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL