Documentation
¶
Index ¶
- Constants
- type Config
- type Logger
- func (o *Logger) BR() (err error)
- func (o *Logger) Close()
- func (o *Logger) Color(s string) (err error)
- func (o *Logger) ColorOnce(s string) (err error)
- func (o *Logger) ColorReset() (err error)
- func (o *Logger) Compact(format string, a ...interface{}) (err error)
- func (o *Logger) Enable(is bool)
- func (o *Logger) Log(a ...interface{}) (err error)
- func (o *Logger) Logf(format string, a ...interface{}) (err error)
- func (o *Logger) Print(format string, a ...interface{}) (err error)
- func (o *Logger) Raw(a ...interface{}) (err error)
Examples ¶
Constants ¶
View Source
const ( CallerNone = callerType(iota + 1) CallerShort CallerLong )
just like Lshortfile/Llongfile in pkg/log
View Source
const ( TimeMS = `15:04:05.000 ` TimeDayMS = `02 15:04:05.000 ` TimeMonthMS = `01-02 15:04:05.000 ` TimeYearMS = `2006-01-02 15:04:05.000 ` Time = `15:04:05 ` TimeDay = `02 15:04:05 ` TimeMonth = `01-02 15:04:05 ` TimeYear = `2006-01-02 15:04:05 ` TimeNS = `15:04:05.000000000 ` )
time format in config
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Filename string
Echo bool // stdout
Append bool
Prefix string
TimeFormat string
Tunnel int // channel buffer size
FileFunc func(t *time.Time) (filename string)
LineFunc func(line *string)
Caller callerType
}
Config ...
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger ...
func NewFunc ¶
NewFunc create a new logger with FileFunc
Example ¶
package main
import (
"time"
"github.com/zhengkai/j"
)
func main() {
jx, _ := j.NewFunc(func(t *time.Time) string {
return t.Format(`log/01-02/15.log`)
})
jx.Log(`file func`)
}
Output:
Click to show internal directories.
Click to hide internal directories.