Documentation
¶
Index ¶
- Constants
- Variables
- func Debug(format string, v ...interface{})
- func Error(format string, v ...interface{})
- func Fatal(format string, v ...interface{})
- func Info(format string, v ...interface{})
- func LevelText(lvl int) string
- func LogWithFormater(lvl int, depth int, layout string, format string, v ...interface{}) string
- func Panic(format string, v ...interface{})
- func Printf(fmtstr string, v ...interface{})
- func Println(v ...interface{})
- func SetBuildDir(dir string)
- func SetFormater(f func(log *Log) string)
- func SetLevel(level int)
- func SetLogTimeFormat(layout string)
- func SetOutput(out io.Writer)
- func SetStructOutput(out ILogWriter)
- func Warn(format string, v ...interface{})
- type FileWriter
- func (w *FileWriter) Init(now time.Time)
- func (w *FileWriter) Save()
- func (w *FileWriter) SetFormater(f func(log *Log) string)
- func (w *FileWriter) Sync() error
- func (w *FileWriter) Write(p []byte) (n int, err error)
- func (w *FileWriter) WriteLog(log *Log) (n int, err error)
- func (w *FileWriter) WriteString(str string) (n int, err error)
- type ILogWriter
- type Log
- type LogWriter
- type Logger
- func (logger *Logger) Debug(format string, v ...interface{})
- func (logger *Logger) Error(format string, v ...interface{})
- func (logger *Logger) Fatal(format string, v ...interface{})
- func (logger *Logger) Info(format string, v ...interface{})
- func (logger *Logger) Panic(format string, v ...interface{})
- func (logger *Logger) Printf(format string, v ...interface{})
- func (logger *Logger) Println(v ...interface{})
- func (logger *Logger) SetFormater(f func(log *Log) string)
- func (logger *Logger) SetLevel(level int)
- func (logger *Logger) SetLogTimeFormat(layout string)
- func (logger *Logger) SetOutput(out io.Writer)
- func (logger *Logger) SetStructOutput(out ILogWriter)
- func (logger *Logger) Warn(format string, v ...interface{})
Constants ¶
View Source
const ( LEVEL_PRINT = iota LEVEL_DEBUG LEVEL_INFO LEVEL_WARN LEVEL_ERROR LEVEL_PANIC LEVEL_FATAL LEVEL_NONE )
Variables ¶
View Source
var ( BuildDir = "" DefaultLogLevel = LEVEL_DEBUG DefaultLogDepth = 2 DefaultLogWriter = os.Stdout DefaultLogTimeLayout = "2006-01-02 15:04:05.000" DefaultLogger = NewLogger() )
Functions ¶
func LogWithFormater ¶
log with formater
Types ¶
type FileWriter ¶
type FileWriter struct {
sync.Mutex
RootDir string
DirFormat string
FileFormat string
TimeBegin int
TimePrefix string
MaxFileSize int
SyncInterval time.Duration
SaveEach bool
EnableBufio bool
Formater func(log *Log) string
// contains filtered or unexported fields
}
file writer
func (*FileWriter) SetFormater ¶
func (w *FileWriter) SetFormater(f func(log *Log) string)
set formater
func (*FileWriter) Sync ¶
func (w *FileWriter) Sync() error
func (*FileWriter) Write ¶
func (w *FileWriter) Write(p []byte) (n int, err error)
io.Writer implementation
func (*FileWriter) WriteLog ¶
func (w *FileWriter) WriteLog(log *Log) (n int, err error)
log writer implementation
func (*FileWriter) WriteString ¶
func (w *FileWriter) WriteString(str string) (n int, err error)
write string
type ILogWriter ¶
log writer interface
type Log ¶
type Log struct {
Time time.Time `json:"Time"`
Depth int `json:"Depth"`
Level int `json:"Level"`
Line int `json:"Line"`
File string `json:"File"`
Value string `json:"Value"`
Logger *Logger `json:"-"`
}
log item
type Logger ¶
type Logger struct {
sync.Mutex
Writer io.Writer
LogWriter ILogWriter
Level int
Layout string
Formater func(log *Log) string
FullPath bool
// contains filtered or unexported fields
}
logger
func (*Logger) SetFormater ¶
set formater
func (*Logger) SetLogTimeFormat ¶
set log time format
func (*Logger) SetStructOutput ¶
func (logger *Logger) SetStructOutput(out ILogWriter)
set struct output
Source Files
¶
- log.go
- logfile.go
- util.go
Click to show internal directories.
Click to hide internal directories.