log4go

package module
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2020 License: BSD-2-Clause Imports: 23 Imported by: 74

README

log4go


Build Status codecov go.dev reference

Please see http://log4go.googlecode.com/ for more log4go usages. My personal package (github.com/AlexStocks/goext/log) wrappered log4go functions further more which provides the most powerful log4go.

Installation:

  • Run go get -u -v github.com/AlexStocks/log4go

Usage:

  • Add the following import:
  import l4g "github.com/AlexStocks/log4go"

  func main() {
  	defer l4g.Close() // to close l4g.Global
  }
get logger
Global logger
import l4g "github.com/alecthomas/log4go"

l4g.Info("hello world")
defer l4g.Close()
NewDefaultLogger
log := l4g.NewDefaultLogger(l4g.INFO)
log.Info("hello world")
defer log.Close()
l4g.Logger
log := make(l4g.Logger)
defer log.Close()
log.AddFilter("stdout", l4g.DEBUG, l4g.NewConsoleLogWriter())
log.Info("hello world")

output log

l4g.Finest()
l4g.Fine()
l4g.Debug()
l4g.Trace()
l4g.Info()
l4g.Warning()
l4g.Error()
l4g.Critical()

UserGuide

Level
FINEST
FINE
DEBUG
TRACE
INFO
WARNING
ERROR
CRITICAL

Feature list:

  • Output colorful terminal log string by log level
  • Output json log
  • Add maxbackup choice in examples.xml to delete out of date log file
  • Output escape query string safety
  • Add filename to every log line
  • Create log path if log path does not exist
  • Add caller option to let log4go do not output file/function-name/line-number
  • Add %P to output process ID
  • Rotate log file daily/hourly
  • Support json/xml/yml configuration file

Documentation

Overview

Package log4go provides level-based and highly configurable logging.

Enhanced Logging

This is inspired by the logging functionality in Java. Essentially, you create a Logger object and create output filters for it. You can send whatever you want to the Logger, and it will filter that based on your settings and send it to the outputs. This way, you can put as much debug code in your program as you want, and when you're done you can filter out the mundane messages so only the important ones show up.

Utility functions are provided to make life easier. Here is some example code to get started:

log := log4go.NewLogger() log.AddFilter("stdout", log4go.DEBUG, log4go.NewConsoleLogWriter()) log.AddFilter("log", log4go.FINE, log4go.NewFileLogWriter("example.log", true)) log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02"))

The first two lines can be combined with the utility NewDefaultLogger:

log := log4go.NewDefaultLogger(log4go.DEBUG) log.AddFilter("log", log4go.FINE, log4go.NewFileLogWriter("example.log", true)) log.Info("The time is now: %s", time.LocalTime().Format("15:04:05 MST 2006/01/02"))

Usage notes:

  • The ConsoleLogWriter does not display the source of the message to standard output, but the FileLogWriter does.
  • The utility functions (Info, Debug, Warn, etc) derive their source from the calling function, and this incurs extra overhead.

Changes from 2.0:

  • The external interface has remained mostly stable, but a lot of the internals have been changed, so if you depended on any of this or created your own LogWriter, then you will probably have to update your code. In particular, Logger is now a map and ConsoleLogWriter is now a channel behind-the-scenes, and the LogWrite method no longer has return values.

Future work: (please let me know if you think I should work on any of these particularly)

  • Logging configuration files ala log4j
  • Have the ability to remove filters?
  • Have GetInfoChannel, GetDebugChannel, etc return a chan string that allows for another method of logging
  • Add an XML filter type

Index

Constants

View Source
const (
	ROT_TYPE_DAY  = RotType(1)
	ROT_TYPE_HOUR = RotType(2)
	// rotate file suffix
	DEF_ROT_TIME_SUFFIX_DAY  = "2006-01-02"
	DEF_ROT_TIME_SUFFIX_HOUR = "2006-01-02_15"
)
View Source
const (
	L4G_VERSION = "log4go-v1.0.6"
	L4G_MAJOR   = 1
	L4G_MINOR   = 0
	L4G_BUILD   = 6
)

Version information

View Source
const (
	DEFAULT_CALLER_LEVEL = 2
	DEFAULT_LOG_BUFSIZE  = 4096
)

***** Constants *****

View Source
const (
	FORMAT_DEFAULT = "[%D %T] [%L] (%S) %M" // [时:分:秒 年月日] [level] (class:file:line) message
	FORMAT_SHORT   = "[%t %d] [%L] %M"      // [小时:分钟 年月日] [level] message
	FORMAT_ABBREV  = "[%L] %M"              // [level] message
)
View Source
const (
	Version     = "1.0.7"
	DATE        = "2020/03/07"
	GETTY_MAJOR = 1
	GETTY_MINOR = 0
	GETTY_BUILD = 7
)

Variables

View Source
var (
	// Normal colors
	// NORMAL   = []byte{'\033', '0', 'm'}
	NORMAL   = []byte{'\033', '0'}
	NBlack   = []byte{'\033', '[', '3', '0', 'm'}
	NRed     = []byte{'\033', '[', '3', '1', 'm'}
	NGreen   = []byte{'\033', '[', '3', '2', 'm'}
	NYellow  = []byte{'\033', '[', '3', '3', 'm'}
	NBlue    = []byte{'\033', '[', '3', '4', 'm'}
	NMagenta = []byte{'\033', '[', '3', '5', 'm'}
	NCyan    = []byte{'\033', '[', '3', '6', 'm'}
	NWhite   = []byte{'\033', '[', '3', '7', 'm'}
	// Bright colors
	BBlack                    = []byte{'\033', '[', '3', '0', ';', '1', 'm'}
	BRed                      = []byte{'\033', '[', '3', '1', ';', '1', 'm'}
	BGreen                    = []byte{'\033', '[', '3', '2', ';', '1', 'm'}
	BYellow                   = []byte{'\033', '[', '3', '3', ';', '1', 'm'}
	BBlue                     = []byte{'\033', '[', '3', '4', ';', '1', 'm'}
	BMagenta                  = []byte{'\033', '[', '3', '5', ';', '1', 'm'}
	BCyan                     = []byte{'\033', '[', '3', '6', ';', '1', 'm'}
	BWhite                    = []byte{'\033', '[', '3', '7', ';', '1', 'm'}
	UnderlineTwinkleHighLight = []byte{'\033', '[', '1', ';', '6', ';', '4', '0', 'm'}
)
View Source
var (
	// LogBufferLength specifies how many log messages a particular log4go
	// logger can buffer at a time before writing them.
	LogBufferLength                     = 128
	SocketLogBufferLength               = 8192
	SockFailWaitTimeout   time.Duration = 1e8 // 100ms
)

***** Variables *****

Functions

func AddFilter

func AddFilter(name string, lvl Level, writer LogWriter)

Wrapper for (*Logger).AddFilter

func CPrintfln

func CPrintfln(w io.Writer, color []byte, logString string)

func Close

func Close()

Wrapper for (*Logger).Close (closes and removes all logwriters)

func Crash

func Crash(args ...interface{})

func Crashf

func Crashf(format string, args ...interface{})

Logs the given message and crashes the program

func Critical

func Critical(arg0 interface{}, args ...interface{}) error

Utility for critical log messages (returns an error for easy function returns) (see Debug() for parameter explanation) These functions will execute a closure exactly once, to build the error message for the return Wrapper for (*Logger).Critical

func Debug

func Debug(arg0 interface{}, args ...interface{})

Utility for debug log messages When given a string as the first argument, this behaves like Logf but with the DEBUG log level (e.g. the first argument is interpreted as a format for the latter arguments) When given a closure of type func()string, this logs the string returned by the closure iff it will be logged. The closure runs at most one time. When given anything else, the log message will be each of the arguments formatted with %v and separated by spaces (ala Sprint). Wrapper for (*Logger).Debug

func Error

func Error(arg0 interface{}, args ...interface{})

Utility for error log messages (returns an error for easy function returns) (see Debug() for parameter explanation) These functions will execute a closure exactly once, to build the error message for the return Wrapper for (*Logger).Error func Error(arg0 interface{}, args ...interface{}) error {

func Exit

func Exit(args ...interface{})

Compatibility with `log`

func Exitf

func Exitf(format string, args ...interface{})

Compatibility with `log`

func Fine

func Fine(arg0 interface{}, args ...interface{})

Utility for fine log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Fine

func Finest

func Finest(arg0 interface{}, args ...interface{})

Utility for finest log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Finest

func FormatLogRecord

func FormatLogRecord(format string, rec *LogRecord) string

Known format codes: %T - Time (15:04:05 MST) %t - Time (15:04) %D - Date (2006/01/02) %d - Date (01/02/06) %L - Level (FNST, FINE, DEBG, TRAC, WARN, EROR, CRIT) %P - Pid of process %S - Source %M - Message Ignores unknown formats Recommended: "[%D %T] [%L] (%S) %M"

func Info

func Info(arg0 interface{}, args ...interface{})

Utility for info log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Info

func LoadConfiguration

func LoadConfiguration(filename string)

Wrapper for (*Logger).LoadConfiguration

func Log

func Log(lvl Level, source, message string)

Send a log message manually Wrapper for (*Logger).Log

func Logc

func Logc(lvl Level, closure func() string)

Send a closure log message Wrapper for (*Logger).Logc

func Logf

func Logf(lvl Level, format string, args ...interface{})

Send a formatted log message easily Wrapper for (*Logger).Logf

func SetCallerFlag added in v1.0.3

func SetCallerFlag(caller bool)

SetCallerFlag enable/disable output caller info (file/func/line)

func SetCallerLevel

func SetCallerLevel(level int)

func SetLogLevel added in v1.0.6

func SetLogLevel(level Level) error

SetLogLevel changes default logger's log level

func Slice added in v1.0.2

func Slice(s string) (b []byte)

func Stderr

func Stderr(args ...interface{})

Compatibility with `log`

func Stderrf

func Stderrf(format string, args ...interface{})

Compatibility with `log`

func Stdout

func Stdout(args ...interface{})

Compatibility with `log`

func Stdoutf

func Stdoutf(format string, args ...interface{})

Compatibility with `log`

func String added in v1.0.2

func String(b []byte) (s string)

func Trace

func Trace(arg0 interface{}, args ...interface{})

Utility for trace log messages (see Debug() for parameter explanation) Wrapper for (*Logger).Trace

func Warn

func Warn(arg0 interface{}, args ...interface{})

Utility for warn log messages (returns an error for easy function returns) (see Debug() for parameter explanation) These functions will execute a closure exactly once, to build the error message for the return Wrapper for (*Logger).Warn func Warn(arg0 interface{}, args ...interface{}) error {

Types

type BufFileWriter

type BufFileWriter struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func (*BufFileWriter) Close

func (w *BufFileWriter) Close() error

func (*BufFileWriter) Flush

func (w *BufFileWriter) Flush()

func (*BufFileWriter) Reset

func (w *BufFileWriter) Reset(filename string, bufSize int)

func (*BufFileWriter) Seek

func (w *BufFileWriter) Seek(offset int64, whence int) (int64, error)

func (*BufFileWriter) Write

func (w *BufFileWriter) Write(p []byte) (int, error)

type ConsoleLogWriter

type ConsoleLogWriter struct {
	LogCloser

	sync.Once
	// contains filtered or unexported fields
}

This is the standard writer that prints to standard output.

func NewConsoleLogWriter

func NewConsoleLogWriter(json bool) *ConsoleLogWriter

This creates a new ConsoleLogWriter

func (*ConsoleLogWriter) Close

func (c *ConsoleLogWriter) Close()

Close stops the logger from sending messages to standard output. Attempts to send log messages to this logger after a Close have undefined behavior.

func (*ConsoleLogWriter) GetCallerFlag added in v1.0.3

func (c *ConsoleLogWriter) GetCallerFlag() bool

This func shows whether output filename/function/lineno info in log

func (*ConsoleLogWriter) LogWrite

func (c *ConsoleLogWriter) LogWrite(rec *LogRecord)

This is the ConsoleLogWriter's output method. This will block if the output buffer is full.

func (*ConsoleLogWriter) SetCallerFlag added in v1.0.3

func (c *ConsoleLogWriter) SetCallerFlag(callerFlag bool)

func (*ConsoleLogWriter) SetFormat

func (c *ConsoleLogWriter) SetFormat(format string)

func (*ConsoleLogWriter) SetJson

func (c *ConsoleLogWriter) SetJson(json bool)

type FileLogWriter

type FileLogWriter struct {
	LogCloser

	sync.Once
	// contains filtered or unexported fields
}

This log writer sends output to a file

func NewFileLogWriter

func NewFileLogWriter(fname string, rotate bool, bufSize int) *FileLogWriter

NewFileLogWriter creates a new LogWriter which writes to the given file and has rotation enabled if rotate is true and set a memory alignment buffer if bufSize is non-zero.

If rotate is true, any time a new log file is opened, the old one is renamed with a .### extension to preserve it. The various Set* methods can be used to configure log rotation based on lines, size, and daily.

The standard log-line format is:

[%D %T] [%L] (%S) %M

func NewXMLLogWriter

func NewXMLLogWriter(fname string, rotate bool, bufSize int) *FileLogWriter

NewXMLLogWriter is a utility method for creating a FileLogWriter set up to output XML record log messages instead of line-based ones.

func (*FileLogWriter) Close

func (w *FileLogWriter) Close()

func (*FileLogWriter) GetCallerFlag added in v1.0.3

func (w *FileLogWriter) GetCallerFlag() bool

This func shows whether output filename/function/lineno info in log

func (*FileLogWriter) LogWrite

func (w *FileLogWriter) LogWrite(rec *LogRecord)

This is the FileLogWriter's output method

func (*FileLogWriter) Rotate

func (w *FileLogWriter) Rotate()

Request that the logs rotate

func (*FileLogWriter) SetCallerFlag added in v1.0.3

func (w *FileLogWriter) SetCallerFlag(flag bool) *FileLogWriter

Set whether output the filename/function name/line number info or not. Must be called before the first log message is written.

func (*FileLogWriter) SetFormat

func (w *FileLogWriter) SetFormat(format string) *FileLogWriter

Set the logging format (chainable). Must be called before the first log message is written.

func (*FileLogWriter) SetHeadFoot

func (w *FileLogWriter) SetHeadFoot(head, foot string) *FileLogWriter

Set the logfile header and footer (chainable). Must be called before the first log message is written. These are formatted similar to the FormatLogRecord (e.g. you can use %D and %T in your header/footer for date and time).

func (*FileLogWriter) SetJson

func (w *FileLogWriter) SetJson(jsonFormat bool) *FileLogWriter

Set the logging json format (chainable). Must be called before the first log message is written.

func (*FileLogWriter) SetRotate

func (w *FileLogWriter) SetRotate(rotate bool) *FileLogWriter

SetRotate changes whether or not the old logs are kept. (chainable) Must be called before the first log message is written. If rotate is false, the files are overwritten; otherwise, they are rotated to another file before the new log is opened.

func (*FileLogWriter) SetRotateDaily

func (w *FileLogWriter) SetRotateDaily(daily bool) *FileLogWriter

Set rotate daily (chainable). Must be called before the first log message is written.

func (*FileLogWriter) SetRotateHourly added in v1.0.3

func (w *FileLogWriter) SetRotateHourly(rotHours int) *FileLogWriter

Set rotate daily (chainable). Must be called before the first log message is written.

func (*FileLogWriter) SetRotateLines

func (w *FileLogWriter) SetRotateLines(maxlines int) *FileLogWriter

Set rotate at linecount (chainable). Must be called before the first log message is written.

func (*FileLogWriter) SetRotateMaxBackup

func (w *FileLogWriter) SetRotateMaxBackup(maxbackup int) *FileLogWriter

Set max backup files. Must be called before the first log message is written.

func (*FileLogWriter) SetRotateParams added in v1.0.4

func (w *FileLogWriter) SetRotateParams(rtype RotType, suffix string, interval int) *FileLogWriter

Set rotate params

func (*FileLogWriter) SetRotateSize

func (w *FileLogWriter) SetRotateSize(maxsize int64) *FileLogWriter

Set rotate at size (chainable). Must be called before the first log message is written.

type Filter

type Filter struct {
	Level Level
	LogWriter
}

A Filter represents the log level below which no log records are written to the associated LogWriter.

type FilterMap

type FilterMap map[string]*Filter

string可以认为是Filter{logger对象}的logger name

type FormatLogWriter

type FormatLogWriter struct {
	sync.Once
	// contains filtered or unexported fields
}

This is the standard writer that prints to standard output.

func NewFormatLogWriter

func NewFormatLogWriter(out io.Writer, format string) *FormatLogWriter

This creates a new FormatLogWriter

func (*FormatLogWriter) Close

func (w *FormatLogWriter) Close()

Close stops the logger from sending messages to standard output. Attempts to send log messages to this logger after a Close have undefined behavior.

func (*FormatLogWriter) GetCallerFlag added in v1.0.3

func (w *FormatLogWriter) GetCallerFlag() bool

This func shows whether output filename/function/lineno info in log

func (*FormatLogWriter) LogWrite

func (w *FormatLogWriter) LogWrite(rec *LogRecord)

This is the FormatLogWriter's output method. This will block if the output buffer is full.

func (*FormatLogWriter) SetCallerFlag added in v1.0.3

func (w *FormatLogWriter) SetCallerFlag(flag bool) *FormatLogWriter

Set whether output the filename/function name/line number info or not. Must be called before the first log message is written.

type Level

type Level int

These are the integer logging levels used by the logger

const (
	FINEST Level = iota
	FINE
	DEBUG
	TRACE
	INFO
	WARNING
	ERROR
	CRITICAL
	LEVEL_END
)

func (Level) String

func (l Level) String() string

type LogCloser added in v1.0.3

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

***** LogCloser *****

func (*LogCloser) IsClosed added in v1.0.3

func (lc *LogCloser) IsClosed(rec LogRecord) bool

notyfy the logger log to end

func (*LogCloser) LogCloserInit added in v1.0.3

func (lc *LogCloser) LogCloserInit()

func (*LogCloser) WaitClosed added in v1.0.3

func (lc *LogCloser) WaitClosed(recQ chan LogRecord)

add nil to end of res and wait that EndNotify is call

type LogRecord

type LogRecord struct {
	Level   Level     `json:"level,omitempty"`     // The log level
	Created time.Time `json:"timestamp,omitempty"` // The time at which the log message was created (nanoseconds)
	Source  string    `json:"source,omitempty"`    // The message source
	Message string    `json:"log,omitempty"`       // The log message
}

A LogRecord contains all of the pertinent information for each message

func (LogRecord) IsNil added in v1.0.3

func (r LogRecord) IsNil() bool

func (LogRecord) JSON

func (r LogRecord) JSON() []byte

不要尝试使用json.Marshal,这个函数使用了反射,效率很低,详细结果见测试 func (r LogRecord) MarshalJSON() ([]byte, error) {

func (LogRecord) MarshalEasyJSON

func (v LogRecord) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (LogRecord) MarshalJSON

func (v LogRecord) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*LogRecord) UnmarshalEasyJSON

func (v *LogRecord) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*LogRecord) UnmarshalJSON

func (v *LogRecord) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type LogWriter

type LogWriter interface {
	// This will be called to log a LogRecord message.
	LogWrite(rec *LogRecord)

	// This should clean up anything lingering about the LogWriter, as it is called before
	// the LogWriter is removed.  LogWrite should not be called after Close.
	Close()

	// This func shows whether output filename/function/lineno info in log
	GetCallerFlag() bool
}

This is an interface for anything that should be able to write logs

type Logger

type Logger struct {
	FilterMap

	sync.Once
	// contains filtered or unexported fields
}

A Logger represents a collection of Filters through which log messages are written.

var (
	Global Logger
)

func NewConsoleLogger

func NewConsoleLogger(lvl Level) Logger

Create a new logger with a "stdout" filter configured to send log messages at or above lvl to standard output.

DEPRECATED: use NewDefaultLogger instead.

func NewDefaultLogger

func NewDefaultLogger(lvl Level) Logger

Create a new logger with a "stdout" filter configured to send log messages at or above lvl to standard output.

func NewLogger

func NewLogger() Logger

Create a new logger.

func (*Logger) AddFilter

func (log *Logger) AddFilter(name string, lvl Level, writer LogWriter)

Add a new LogWriter to the Logger which will only log messages at lvl or higher. This function should not be called from multiple goroutines. Returns the logger for chaining. func (log *Logger) AddFilter(name string, lvl Level, writer LogWriter) Logger {

func (Logger) Close

func (log Logger) Close()

Closes all log writers in preparation for exiting the program or a reconfiguration of logging. Calling this is not really imperative, unless you want to guarantee that all log messages are written. Close removes all filters (and thus all LogWriters) from the logger.

func (Logger) Critic

func (log Logger) Critic(arg0 interface{}, args ...interface{}) error

func (Logger) Critical

func (log Logger) Critical(arg0 interface{}, args ...interface{}) error

Critical logs a message at the critical log level and returns the formatted error, See Warn for an explanation of the performance and Debug for an explanation of the parameters.

func (Logger) Debug

func (log Logger) Debug(arg0 interface{}, args ...interface{})

Debug is a utility method for debug log messages. The behavior of Debug depends on the first argument:

  • arg0 is a string When given a string as the first argument, this behaves like Logf but with the DEBUG log level: the first argument is interpreted as a format for the latter arguments.
  • arg0 is a func()string When given a closure of type func()string, this logs the string returned by the closure iff it will be logged. The closure runs at most one time.
  • arg0 is interface{} When given anything else, the log message will be each of the arguments formatted with %v and separated by spaces (ala Sprint).

func (Logger) Error

func (log Logger) Error(arg0 interface{}, args ...interface{}) error

Error logs a message at the error log level and returns the formatted error, See Warn for an explanation of the performance and Debug for an explanation of the parameters.

func (Logger) Fine

func (log Logger) Fine(arg0 interface{}, args ...interface{})

Fine logs a message at the fine log level. See Debug for an explanation of the arguments.

func (Logger) Finest

func (log Logger) Finest(arg0 interface{}, args ...interface{})

Finest logs a message at the finest log level. See Debug for an explanation of the arguments.

func (Logger) Info

func (log Logger) Info(arg0 interface{}, args ...interface{})

Info logs a message at the info log level. See Debug for an explanation of the arguments.

func (*Logger) LoadConfiguration

func (log *Logger) LoadConfiguration(filename string) Logger

Load XML configuration; see examples/example.xml or examples.json for documentation

func (Logger) Log

func (log Logger) Log(lvl Level, source, message string)

Send a log message with manual level, source, and message.

func (Logger) Logc

func (log Logger) Logc(lvl Level, closure func() string)

Logc logs a string returned by the closure at the given log level, using the caller as its source. If no log message would be written, the closure is never called.

func (Logger) Logf

func (log Logger) Logf(lvl Level, format string, args ...interface{})

Logf logs a formatted log message at the given log level, using the caller as its source.

func (Logger) SetAsDefaultLogger

func (log Logger) SetAsDefaultLogger() Logger

func (Logger) Trace

func (log Logger) Trace(arg0 interface{}, args ...interface{})

Trace logs a message at the trace log level. See Debug for an explanation of the arguments.

func (Logger) Warn

func (log Logger) Warn(arg0 interface{}, args ...interface{}) error

Warn logs a message at the warning log level and returns the formatted error. At the warning level and higher, there is no performance benefit if the message is not actually logged, because all formats are processed and all closures are executed to format the error message. See Debug for further explanation of the arguments.

type RotType added in v1.0.4

type RotType int32

type SocketLogWriter

type SocketLogWriter struct {
	LogCloser

	sync.Once
	// contains filtered or unexported fields
}

This log writer sends output to a socket

func NewSocketLogWriter

func NewSocketLogWriter(proto, hostport string) *SocketLogWriter

func (*SocketLogWriter) Close

func (w *SocketLogWriter) Close()

func (*SocketLogWriter) GetCallerFlag added in v1.0.3

func (w *SocketLogWriter) GetCallerFlag() bool

This func shows whether output filename/function/lineno info in log

func (*SocketLogWriter) LogWrite

func (w *SocketLogWriter) LogWrite(rec *LogRecord)

This is the SocketLogWriter's output method

func (*SocketLogWriter) SetCallerFlag added in v1.0.3

func (w *SocketLogWriter) SetCallerFlag(flag bool) *SocketLogWriter

Set whether output the filename/function name/line number info or not. Must be called before the first log message is written.

Directories

Path Synopsis
examples
net

Jump to

Keyboard shortcuts

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