forked from AdguardTeam/AdGuardHome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
400 additions
and
365 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,11 @@ | ||
//go:build darwin || freebsd || linux || openbsd | ||
//go:build unix | ||
|
||
package aghos | ||
|
||
import ( | ||
"os" | ||
"os/signal" | ||
|
||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func notifyReconfigureSignal(c chan<- os.Signal) { | ||
signal.Notify(c, unix.SIGHUP) | ||
} | ||
|
||
func isReconfigureSignal(sig os.Signal) (ok bool) { | ||
return sig == unix.SIGHUP | ||
} | ||
|
||
func sendShutdownSignal(_ chan<- os.Signal) { | ||
// On Unix we are already notified by the system. | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,39 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"log/slog" | ||
"os" | ||
|
||
"github.com/AdguardTeam/AdGuardHome/internal/aghos" | ||
"github.com/AdguardTeam/golibs/log" | ||
"github.com/AdguardTeam/golibs/logutil/slogutil" | ||
) | ||
|
||
// syslogServiceName is the name of the AdGuard Home service used for writing | ||
// logs to the system log. | ||
const syslogServiceName = "AdGuardHome" | ||
|
||
// setLog sets up the text logging. | ||
// | ||
// TODO(a.garipov): Add parameters from configuration file. | ||
func setLog(opts *options) (err error) { | ||
// 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": | ||
log.SetOutput(os.Stdout) | ||
output = os.Stdout | ||
case "stderr": | ||
log.SetOutput(os.Stderr) | ||
output = os.Stderr | ||
case "syslog": | ||
err = aghos.ConfigureSyslog(syslogServiceName) | ||
if err != nil { | ||
return fmt.Errorf("initializing syslog: %w", err) | ||
} | ||
// TODO(a.garipov): Add a syslog handler to golibs. | ||
default: | ||
// TODO(a.garipov): Use the path. | ||
// TODO(a.garipov): Use the path. | ||
} | ||
|
||
lvl := slog.LevelInfo | ||
if opts.verbose { | ||
log.SetLevel(log.DEBUG) | ||
log.Debug("verbose logging enabled") | ||
lvl = slog.LevelDebug | ||
} | ||
|
||
return nil | ||
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, | ||
}) | ||
} |
Oops, something went wrong.