mirror of
https://github.com/mjl-/mox.git
synced 2024-12-26 08:23:48 +03:00
add "warn" log level
now that we are using slog, which has them. and we already could use them for a deprecation warning.
This commit is contained in:
parent
41e3d1af10
commit
1abadc5499
3 changed files with 16 additions and 2 deletions
14
mlog/log.go
14
mlog/log.go
|
@ -71,6 +71,7 @@ var (
|
|||
LevelTrace = slog.LevelDebug - 4
|
||||
LevelDebug = slog.LevelDebug
|
||||
LevelInfo = slog.LevelInfo
|
||||
LevelWarn = slog.LevelWarn
|
||||
LevelError = slog.LevelError
|
||||
LevelFatal = slog.LevelError + 4 // Printed regardless of configured log level.
|
||||
LevelPrint = slog.LevelError + 8 // Printed regardless of configured log level.
|
||||
|
@ -83,6 +84,7 @@ var LevelStrings = map[slog.Level]string{
|
|||
LevelTrace: "trace",
|
||||
LevelDebug: "debug",
|
||||
LevelInfo: "info",
|
||||
LevelWarn: "warn",
|
||||
LevelError: "error",
|
||||
LevelFatal: "fatal",
|
||||
LevelPrint: "print",
|
||||
|
@ -95,6 +97,7 @@ var Levels = map[string]slog.Level{
|
|||
"trace": LevelTrace,
|
||||
"debug": LevelDebug,
|
||||
"info": LevelInfo,
|
||||
"warn": LevelWarn,
|
||||
"error": LevelError,
|
||||
"fatal": LevelFatal,
|
||||
"print": LevelPrint,
|
||||
|
@ -207,6 +210,17 @@ func (l Log) Infox(msg string, err error, attrs ...slog.Attr) {
|
|||
l.Logger.LogAttrs(noctx, LevelInfo, msg, attrs...)
|
||||
}
|
||||
|
||||
func (l Log) Warn(msg string, attrs ...slog.Attr) {
|
||||
l.Logger.LogAttrs(noctx, LevelWarn, msg, attrs...)
|
||||
}
|
||||
|
||||
func (l Log) Warnx(msg string, err error, attrs ...slog.Attr) {
|
||||
if err != nil {
|
||||
attrs = append([]slog.Attr{errAttr(err)}, attrs...)
|
||||
}
|
||||
l.Logger.LogAttrs(noctx, LevelWarn, msg, attrs...)
|
||||
}
|
||||
|
||||
func (l Log) Error(msg string, attrs ...slog.Attr) {
|
||||
l.Logger.LogAttrs(noctx, LevelError, msg, attrs...)
|
||||
}
|
||||
|
|
|
@ -1343,7 +1343,7 @@ func prepareDynamicConfig(ctx context.Context, log mlog.Log, dynamicPath string,
|
|||
if !ok {
|
||||
addErrorf("could not find localpart %q to replace with address in destinations", lp)
|
||||
} else {
|
||||
log.Error(`deprecation warning: support for account destination addresses specified as just localpart ("username") instead of full email address will be removed in the future; update domains.conf, for each Account, for each Destination, ensure each key is an email address by appending "@" and the default domain for the account`,
|
||||
log.Warn(`deprecation warning: support for account destination addresses specified as just localpart ("username") instead of full email address will be removed in the future; update domains.conf, for each Account, for each Destination, ensure each key is an email address by appending "@" and the default domain for the account`,
|
||||
slog.Any("localpart", lp),
|
||||
slog.Any("address", addr),
|
||||
slog.String("account", accName))
|
||||
|
|
|
@ -301,7 +301,7 @@ const config = async () => {
|
|||
const loglevels = async () => {
|
||||
const loglevels = await api.LogLevels()
|
||||
|
||||
const levels = ['error', 'info', 'debug', 'trace', 'traceauth', 'tracedata']
|
||||
const levels = ['error', 'info', 'warn', 'debug', 'trace', 'traceauth', 'tracedata']
|
||||
|
||||
let form, fieldset, pkg, level
|
||||
|
||||
|
|
Loading…
Reference in a new issue