// NewLogSink creates a new *LogSink for GAE func NewLogSink(format string) *LogSink { return &LogSink{ formatter: wcg.NewLogRecordFormatter(format), ctx: nil, bigquery: nil, } }
// 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, } }
func newIOLogSinkFromConfig(cfg *logSinkFileConfig) *IOLogSink { return &IOLogSink{ formatter: wcg.NewLogRecordFormatter(cfg.Format), factory: cfg.newFactory(), color: cfg.Color, stacklevel: cfg.StackLevel, } }
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) }
// 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, } }