NewLogger constructs a Logger that writes to stdout. It logs at the specified Log level and above. It decorates Log lines with the Log level, date, time, and prepend.
(level int, prepend string)
| 34 | // It logs at the specified Log level and above. |
| 35 | // It decorates Log lines with the Log level, date, time, and prepend. |
| 36 | func NewLogger(level int, prepend string) *Logger { |
| 37 | logger := &Logger{DiscardLogf, DiscardLogf} |
| 38 | logf := func(prefix string) func(string, ...any) { |
| 39 | return log.New(os.Stdout, prefix+": "+prepend, log.Ldate|log.Ltime).Printf |
| 40 | } |
| 41 | if level >= LogLevelVerbose { |
| 42 | logger.Verbosef = logf("DEBUG") |
| 43 | } |
| 44 | if level >= LogLevelError { |
| 45 | logger.Errorf = logf("ERROR") |
| 46 | } |
| 47 | return logger |
| 48 | } |
no outgoing calls