|
39 | 39 | // This package provides several flags that modify this behavior.
|
40 | 40 | // As a result, flag.Parse must be called before any logging is done.
|
41 | 41 | //
|
42 |
| -// -logtostderr=true |
43 |
| -// Logs are written to standard error instead of to files. |
44 |
| -// This shortcuts most of the usual output routing: |
45 |
| -// -alsologtostderr, -stderrthreshold and -log_dir have no |
46 |
| -// effect and output redirection at runtime with SetOutput is |
47 |
| -// ignored. |
48 |
| -// -alsologtostderr=false |
49 |
| -// Logs are written to standard error as well as to files. |
50 |
| -// -stderrthreshold=ERROR |
51 |
| -// Log events at or above this severity are logged to standard |
52 |
| -// error as well as to files. |
53 |
| -// -log_dir="" |
54 |
| -// Log files will be written to this directory instead of the |
55 |
| -// default temporary directory. |
| 42 | +// -logtostderr=true |
| 43 | +// Logs are written to standard error instead of to files. |
| 44 | +// This shortcuts most of the usual output routing: |
| 45 | +// -alsologtostderr, -stderrthreshold and -log_dir have no |
| 46 | +// effect and output redirection at runtime with SetOutput is |
| 47 | +// ignored. |
| 48 | +// -alsologtostderr=false |
| 49 | +// Logs are written to standard error as well as to files. |
| 50 | +// -stderrthreshold=ERROR |
| 51 | +// Log events at or above this severity are logged to standard |
| 52 | +// error as well as to files. |
| 53 | +// -log_dir="" |
| 54 | +// Log files will be written to this directory instead of the |
| 55 | +// default temporary directory. |
56 | 56 | //
|
57 |
| -// Other flags provide aids to debugging. |
58 |
| -// |
59 |
| -// -log_backtrace_at="" |
60 |
| -// When set to a file and line number holding a logging statement, |
61 |
| -// such as |
62 |
| -// -log_backtrace_at=gopherflakes.go:234 |
63 |
| -// a stack trace will be written to the Info log whenever execution |
64 |
| -// hits that statement. (Unlike with -vmodule, the ".go" must be |
65 |
| -// present.) |
66 |
| -// -v=0 |
67 |
| -// Enable V-leveled logging at the specified level. |
68 |
| -// -vmodule="" |
69 |
| -// The syntax of the argument is a comma-separated list of pattern=N, |
70 |
| -// where pattern is a literal file name (minus the ".go" suffix) or |
71 |
| -// "glob" pattern and N is a V level. For instance, |
72 |
| -// -vmodule=gopher*=3 |
73 |
| -// sets the V level to 3 in all Go files whose names begin "gopher". |
| 57 | +// Other flags provide aids to debugging. |
74 | 58 | //
|
| 59 | +// -log_backtrace_at="" |
| 60 | +// When set to a file and line number holding a logging statement, |
| 61 | +// such as |
| 62 | +// -log_backtrace_at=gopherflakes.go:234 |
| 63 | +// a stack trace will be written to the Info log whenever execution |
| 64 | +// hits that statement. (Unlike with -vmodule, the ".go" must be |
| 65 | +// present.) |
| 66 | +// -v=0 |
| 67 | +// Enable V-leveled logging at the specified level. |
| 68 | +// -vmodule="" |
| 69 | +// The syntax of the argument is a comma-separated list of pattern=N, |
| 70 | +// where pattern is a literal file name (minus the ".go" suffix) or |
| 71 | +// "glob" pattern and N is a V level. For instance, |
| 72 | +// -vmodule=gopher*=3 |
| 73 | +// sets the V level to 3 in all Go files whose names begin "gopher". |
75 | 74 | package klog
|
76 | 75 |
|
77 | 76 | import (
|
@@ -633,8 +632,11 @@ It returns a buffer containing the formatted header and the user's file and line
|
633 | 632 | The depth specifies how many stack frames above lives the source line to be identified in the log message.
|
634 | 633 |
|
635 | 634 | Log lines have this form:
|
| 635 | +
|
636 | 636 | Lmmdd hh:mm:ss.uuuuuu threadid file:line] msg...
|
| 637 | +
|
637 | 638 | where the fields are defined as follows:
|
| 639 | +
|
638 | 640 | L A single character, representing the log level (eg 'I' for INFO)
|
639 | 641 | mm The month (zero padded; ie May is '05')
|
640 | 642 | dd The day (zero padded)
|
@@ -1298,9 +1300,13 @@ func newVerbose(level Level, b bool) Verbose {
|
1298 | 1300 | // The returned value is a struct of type Verbose, which implements Info, Infoln
|
1299 | 1301 | // and Infof. These methods will write to the Info log if called.
|
1300 | 1302 | // Thus, one may write either
|
| 1303 | +// |
1301 | 1304 | // if klog.V(2).Enabled() { klog.Info("log this") }
|
| 1305 | +// |
1302 | 1306 | // or
|
| 1307 | +// |
1303 | 1308 | // klog.V(2).Info("log this")
|
| 1309 | +// |
1304 | 1310 | // The second form is shorter but the first is cheaper if logging is off because it does
|
1305 | 1311 | // not evaluate its arguments.
|
1306 | 1312 | //
|
@@ -1582,10 +1588,10 @@ func ErrorSDepth(depth int, err error, msg string, keysAndValues ...interface{})
|
1582 | 1588 | //
|
1583 | 1589 | // Callers who want more control over handling of fatal events may instead use a
|
1584 | 1590 | // combination of different functions:
|
1585 |
| -// - some info or error logging function, optionally with a stack trace |
1586 |
| -// value generated by github.com/go-logr/lib/dbg.Backtrace |
1587 |
| -// - Flush to flush pending log data |
1588 |
| -// - panic, os.Exit or returning to the caller with an error |
| 1591 | +// - some info or error logging function, optionally with a stack trace |
| 1592 | +// value generated by github.com/go-logr/lib/dbg.Backtrace |
| 1593 | +// - Flush to flush pending log data |
| 1594 | +// - panic, os.Exit or returning to the caller with an error |
1589 | 1595 | //
|
1590 | 1596 | // Arguments are handled in the manner of fmt.Print; a newline is appended if missing.
|
1591 | 1597 | func Fatal(args ...interface{}) {
|
|
0 commit comments