ErrNoLog is the error we return if no log file has yet been created for the specified log type.
var ErrNoLog = errors.New("log file not yet created")
MaxSize is the maximum size of a log file in bytes.
var MaxSize uint64 = 1024 * 1024 * 1800
Stats tracks the number of lines of output and number of bytes per severity level. Values must be read with atomic.LoadInt64.
var Stats struct { Info, Warning, Error OutputStats }
func CopyStandardLogTo(name string)
CopyStandardLogTo arranges for messages written to the Go "log" package's default logs to also appear in the Google logs for the named and lower severities. Subsequent changes to the standard log's default output location or format may break this behavior.
Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not recognized, CopyStandardLogTo panics.
func Error(args ...any)
Error logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func ErrorContext(ctx context.Context, args ...any)
ErrorContext is like Error, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ErrorContextDepth(ctx context.Context, depth int, args ...any)
ErrorContextDepth is like ErrorDepth, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ErrorContextDepthf(ctx context.Context, depth int, format string, args ...any)
ErrorContextDepthf is like ErrorDepthf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ErrorContextf(ctx context.Context, format string, args ...any)
ErrorContextf is like Errorf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ErrorDepth(depth int, args ...any)
ErrorDepth acts as Error but uses depth to determine which call frame to log. ErrorDepth(0, "msg") is the same as Error("msg").
func ErrorDepthf(depth int, format string, args ...any)
ErrorDepthf acts as Errorf but uses depth to determine which call frame to log. ErrorDepthf(0, "msg") is the same as Errorf("msg").
func Errorf(format string, args ...any)
Errorf logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Errorln(args ...any)
Errorln logs to the ERROR, WARNING, and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func Exit(args ...any)
Exit logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func ExitContext(ctx context.Context, args ...any)
ExitContext is like Exit, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ExitContextDepth(ctx context.Context, depth int, args ...any)
ExitContextDepth is like ExitDepth, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ExitContextDepthf(ctx context.Context, depth int, format string, args ...any)
ExitContextDepthf is like ExitDepthf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ExitContextf(ctx context.Context, format string, args ...any)
ExitContextf is like Exitf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func ExitDepth(depth int, args ...any)
ExitDepth acts as Exit but uses depth to determine which call frame to log. ExitDepth(0, "msg") is the same as Exit("msg").
func ExitDepthf(depth int, format string, args ...any)
ExitDepthf acts as Exitf but uses depth to determine which call frame to log. ExitDepthf(0, "msg") is the same as Exitf("msg").
func Exitf(format string, args ...any)
Exitf logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Exitln(args ...any)
Exitln logs to the FATAL, ERROR, WARNING, and INFO logs, then calls os.Exit(1).
func Fatal(args ...any)
Fatal logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(2). Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func FatalContext(ctx context.Context, args ...any)
FatalContext is like Fatal, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func FatalContextDepth(ctx context.Context, depth int, args ...any)
FatalContextDepth is like FatalDepth, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func FatalContextDepthf(ctx context.Context, depth int, format string, args ...any)
FatalContextDepthf is like FatalDepthf, but with an extra context.Context parameter.
func FatalContextf(ctx context.Context, format string, args ...any)
FatalContextf is like Fatalf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func FatalDepth(depth int, args ...any)
FatalDepth acts as Fatal but uses depth to determine which call frame to log. FatalDepth(0, "msg") is the same as Fatal("msg").
func FatalDepthf(depth int, format string, args ...any)
FatalDepthf acts as Fatalf but uses depth to determine which call frame to log. FatalDepthf(0, "msg") is the same as Fatalf("msg").
func Fatalf(format string, args ...any)
Fatalf logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(2). Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Fatalln(args ...any)
Fatalln logs to the FATAL, ERROR, WARNING, and INFO logs, including a stack trace of all running goroutines, then calls os.Exit(2). Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func Flush()
Flush flushes all pending log I/O.
func Info(args ...any)
Info logs to the INFO log. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func InfoContext(ctx context.Context, args ...any)
InfoContext is like Info, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func InfoContextDepth(ctx context.Context, depth int, args ...any)
InfoContextDepth is like InfoDepth, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func InfoContextDepthf(ctx context.Context, depth int, format string, args ...any)
InfoContextDepthf is like InfoDepthf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func InfoContextf(ctx context.Context, format string, args ...any)
InfoContextf is like Infof, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func InfoDepth(depth int, args ...any)
InfoDepth calls Info from a different depth in the call stack. This enables a callee to emit logs that use the callsite information of its caller or any other callers in the stack. When depth == 0, the original callee's line information is emitted. When depth > 0, depth frames are skipped in the call stack and the final frame is treated like the original callee to Info.
func InfoDepthf(depth int, format string, args ...any)
InfoDepthf acts as InfoDepth but with format string.
func Infof(format string, args ...any)
Infof logs to the INFO log. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Infoln(args ...any)
Infoln logs to the INFO log. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
func Names(s string) ([]string, error)
Names returns the names of the log files holding the FATAL, ERROR, WARNING, or INFO logs. Returns ErrNoLog if the log for the given level doesn't exist (e.g. because no messages of that level have been written). This may return multiple names if the log type requested has rolled over.
func NewStandardLogger(name string) *stdLog.Logger
NewStandardLogger returns a Logger that writes to the Google logs for the named and lower severities.
Valid names are "INFO", "WARNING", "ERROR", and "FATAL". If the name is not recognized, NewStandardLogger panics.
func Warning(args ...any)
Warning logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
func WarningContext(ctx context.Context, args ...any)
WarningContext is like Warning, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func WarningContextDepth(ctx context.Context, depth int, args ...any)
WarningContextDepth is like WarningDepth, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func WarningContextDepthf(ctx context.Context, depth int, format string, args ...any)
WarningContextDepthf is like WarningDepthf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func WarningContextf(ctx context.Context, format string, args ...any)
WarningContextf is like Warningf, but with an extra context.Context parameter. The context is used to pass the Trace Context to log sinks.
func WarningDepth(depth int, args ...any)
WarningDepth acts as Warning but uses depth to determine which call frame to log. WarningDepth(0, "msg") is the same as Warning("msg").
func WarningDepthf(depth int, format string, args ...any)
WarningDepthf acts as Warningf but uses depth to determine which call frame to log. WarningDepthf(0, "msg") is the same as Warningf("msg").
func Warningf(format string, args ...any)
Warningf logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Printf; a newline is appended if missing.
func Warningln(args ...any)
Warningln logs to the WARNING and INFO logs. Arguments are handled in the manner of fmt.Println; a newline is appended if missing.
Level specifies a level of verbosity for V logs. The -v flag is of type Level and should be modified only through the flag.Value interface.
type Level int32
func (l *Level) Get() any
Get is part of the flag.Value interface.
func (l *Level) Set(value string) error
Set is part of the flag.Value interface.
func (l *Level) String() string
String is part of the flag.Value interface.
OutputStats tracks the number of output lines and bytes written.
type OutputStats struct {
// contains filtered or unexported fields
}
func (s *OutputStats) Bytes() int64
Bytes returns the number of bytes written.
func (s *OutputStats) Lines() int64
Lines returns the number of lines written.
Verbose is a boolean type that implements Infof (like Printf) etc. See the documentation of V for more information.
type Verbose bool
func V(level Level) Verbose
V reports whether verbosity at the call site is at least the requested level. The returned value is a boolean of type Verbose, which implements Info, Infoln and Infof. These methods will write to the Info log if called. Thus, one may write either
if glog.V(2) { glog.Info("log this") }
or
glog.V(2).Info("log this")
The second form is shorter but the first is cheaper if logging is off because it does not evaluate its arguments.
Whether an individual call to V generates a log record depends on the setting of the -v and --vmodule flags; both are off by default. If the level in the call to V is at most the value of -v, or of -vmodule for the source file containing the call, the V call will log.
func VDepth(depth int, level Level) Verbose
VDepth acts as V but uses depth to determine which call frame to check vmodule for. VDepth(0, level) is the same as V(level).
func (v Verbose) Info(args ...any)
Info is equivalent to the global Info function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) InfoContext(ctx context.Context, args ...any)
InfoContext is equivalent to the global InfoContext function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) InfoContextDepth(ctx context.Context, depth int, args ...any)
InfoContextDepth is equivalent to the global InfoContextDepth function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) InfoContextDepthf(ctx context.Context, depth int, format string, args ...any)
InfoContextDepthf is equivalent to the global InfoContextDepthf function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) InfoContextf(ctx context.Context, format string, args ...any)
InfoContextf is equivalent to the global InfoContextf function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) InfoDepth(depth int, args ...any)
InfoDepth is equivalent to the global InfoDepth function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) InfoDepthf(depth int, format string, args ...any)
InfoDepthf is equivalent to the global InfoDepthf function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) Infof(format string, args ...any)
Infof is equivalent to the global Infof function, guarded by the value of v. See the documentation of V for usage.
func (v Verbose) Infoln(args ...any)
Infoln is equivalent to the global Infoln function, guarded by the value of v. See the documentation of V for usage.
Name | Synopsis |
---|---|
.. |