示例#1
0
文件: io.go 项目: speedland/wcg
func NewIOLogSinkFromConfig(cfg *logSinkFileConfig) *IOLogSink {
	return &IOLogSink{
		formatter:  wcg.NewLogRecordFormatter(cfg.Format),
		factory:    cfg.newFactory(),
		color:      cfg.Color,
		stacklevel: cfg.StackLevel,
	}
}
示例#2
0
文件: io.go 项目: speedland/wcg
// Return a new IOLogSink object.
// format string can have following variables.
//
//   - $TIMESTAMP   : timestamp of a log record
//   - $LOGLEVEL    : log level
//   - $SOURCE_FILE : source file name where a record is produced.
//   - $SOURCE_LINE : a line no of source file where a record is produced.
//   - $GOROUTINE   : Goroutine ID
//   - $SESSSION_ID : Session ID
//   - $REQUEST_ID  : Request ID
//   - $USER_ID     : User ID
//   - $TEXT        : text message produced by app.
//
// and if it is "", "[$GOROUTINE:$USER_ID:$SESSION_ID:$REQUEST_ID] $TEXT ($SOURCE_FILE#$SOURCE_LINE)" is used.
func NewIOLogSink(format string, writer io.Writer) *IOLogSink {
	return &IOLogSink{
		formatter: wcg.NewLogRecordFormatter(format),
		factory:   &writerFactory{writer},
	}
}