New logs to the provided io.Writer.
(w io.Writer, verbose bool)
| 24 | |
| 25 | // New logs to the provided io.Writer. |
| 26 | func New(w io.Writer, verbose bool) Func { |
| 27 | return func(l Level, msg string, args ...any) { |
| 28 | if !verbose { |
| 29 | switch l { |
| 30 | case LevelDebug, LevelTrace: |
| 31 | return |
| 32 | } |
| 33 | } |
| 34 | _, _ = fmt.Fprintf(w, msg, args...) |
| 35 | if !strings.HasSuffix(msg, "\n") { |
| 36 | _, _ = fmt.Fprintf(w, "\n") |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // Wrap wraps the provided LogFuncs into a single Func. |
| 42 | func Wrap(fs ...Func) Func { |
no outgoing calls