Added unit tests, documentation and function descriptions across the board. Increased cyclop complexity threshold to 15 which is a bit more sane than 10 and excluded _test.go files from linters.
This commit is contained in:
1 parent
005b335371
commit
7fd321df97
31 files changed
+4106
-1
No files matched your search
@@ -25,6 +25,9 @@ func EnableDebug() {
|
||||
}
|
||||
}
|
||||
|
||||
// LogToFile sends all logging to logfile as JSON, replacing the default slog
|
||||
// logger. The file is created if needed and appended to; any log file opened
|
||||
// by an earlier call is closed.
|
||||
func LogToFile(logfile string) error {
|
||||
if fileLogger != nil {
|
||||
(*fileLogger).Close()
|
||||
@@ -47,6 +50,7 @@ func LogToFile(logfile string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Shutdown closes the log file opened by LogToFile, if any.
|
||||
func Shutdown() error {
|
||||
var err error = nil
|
||||
if fileLogger != nil {
|
||||
@@ -56,6 +60,8 @@ func Shutdown() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// LogToTerminal sends all logging to stdout as coloured text, replacing the
|
||||
// default slog logger.
|
||||
func LogToTerminal() {
|
||||
opts := &tint.Options{
|
||||
Level: &logLevel,
|
||||
@@ -72,10 +78,12 @@ func IsJSONHandler(h slog.Handler) bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
// IsFileLogger reports whether logging currently goes to a file.
|
||||
func IsFileLogger() bool {
|
||||
return fileLogger != nil
|
||||
}
|
||||
|
||||
// IsDebugEnabled reports whether debug messages are logged.
|
||||
func IsDebugEnabled() bool {
|
||||
return logLevel.Level() <= slog.LevelDebug
|
||||
}
|
||||
Reference in new issue
Block a user