예제 #1
0
파일: logger.go 프로젝트: speedland/service
// NewLogSink creates a new *LogSink for GAE
func NewLogSink(format string) *LogSink {
	return &LogSink{
		formatter: wcg.NewLogRecordFormatter(format),
		ctx:       nil,
		bigquery:  nil,
	}
}
예제 #2
0
파일: io.go 프로젝트: speedland/service
// NewIOLogSink creates 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, useColor bool) *IOLogSink {
	return &IOLogSink{
		formatter: wcg.NewLogRecordFormatter(format),
		factory:   &writerFactory{writer},
		color:     useColor,
	}
}
예제 #3
0
파일: io.go 프로젝트: speedland/service
func newIOLogSinkFromConfig(cfg *logSinkFileConfig) *IOLogSink {
	return &IOLogSink{
		formatter:  wcg.NewLogRecordFormatter(cfg.Format),
		factory:    cfg.newFactory(),
		color:      cfg.Color,
		stacklevel: cfg.StackLevel,
	}
}
예제 #4
0
파일: io.go 프로젝트: speedland/service
func UseStdout() {
	stdout := &IOLogSink{}
	stdout.formatter = wcg.NewLogRecordFormatter("")
	stdout.factory = &writerFactory{os.Stdout}
	stdout.color = true
	stdout.stacklevel = wcg.LogLevelDebug
	wcg.DefaultLogConfig.AddSink(stdout, wcg.LogLevelDebug)
}
예제 #5
0
파일: logger.go 프로젝트: speedland/service
// NewLogSinkWithContext creates a new *LogSink for GAE
func NewLogSinkWithContext(format string, ctx context.Context) *LogSink {
	var _bq *bigquery.Service
	if LogSinkConfig.IsBigQueryEnabled() {
		client, err := bq.NewHTTPClient(ctx)
		if err == nil {
			_bq, _ = bigquery.New(client)
		}
	}
	return &LogSink{
		formatter: wcg.NewLogRecordFormatter(format),
		ctx:       ctx,
		bigquery:  _bq,
	}
}