mirror of
https://github.com/AdguardTeam/AdGuardHome.git
synced 2024-12-24 15:48:18 +03:00
1d6d85cff4
Squashed commit of the following: commit586b0eb180
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Nov 12 19:58:56 2024 +0300 next: upd more commitd729aa150f
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Tue Nov 12 16:53:15 2024 +0300 next/websvc: upd more commit0c64e6cfc6
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Mon Nov 11 21:08:51 2024 +0300 next: upd more commit05eec75222
Author: Ainar Garipov <A.Garipov@AdGuard.COM> Date: Fri Nov 8 19:20:02 2024 +0300 next: upd code
39 lines
787 B
Go
39 lines
787 B
Go
package cmd
|
|
|
|
import (
|
|
"io"
|
|
"log/slog"
|
|
"os"
|
|
|
|
"github.com/AdguardTeam/golibs/logutil/slogutil"
|
|
)
|
|
|
|
// newBaseLogger constructs a base logger based on the command-line options.
|
|
// opts must not be nil.
|
|
func newBaseLogger(opts *options) (baseLogger *slog.Logger) {
|
|
var output io.Writer
|
|
switch opts.confFile {
|
|
case "stdout":
|
|
output = os.Stdout
|
|
case "stderr":
|
|
output = os.Stderr
|
|
case "syslog":
|
|
// TODO(a.garipov): Add a syslog handler to golibs.
|
|
default:
|
|
// TODO(a.garipov): Use the path.
|
|
}
|
|
|
|
lvl := slog.LevelInfo
|
|
if opts.verbose {
|
|
lvl = slog.LevelDebug
|
|
}
|
|
|
|
return slogutil.New(&slogutil.Config{
|
|
Output: output,
|
|
// TODO(a.garipov): Get from config?
|
|
Format: slogutil.FormatText,
|
|
Level: lvl,
|
|
// TODO(a.garipov): Get from config.
|
|
AddTimestamp: true,
|
|
})
|
|
}
|