mirror of
https://github.com/mjl-/mox.git
synced 2024-12-27 08:53: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
|
LevelTrace = slog.LevelDebug - 4
|
||||||
LevelDebug = slog.LevelDebug
|
LevelDebug = slog.LevelDebug
|
||||||
LevelInfo = slog.LevelInfo
|
LevelInfo = slog.LevelInfo
|
||||||
|
LevelWarn = slog.LevelWarn
|
||||||
LevelError = slog.LevelError
|
LevelError = slog.LevelError
|
||||||
LevelFatal = slog.LevelError + 4 // Printed regardless of configured log level.
|
LevelFatal = slog.LevelError + 4 // Printed regardless of configured log level.
|
||||||
LevelPrint = slog.LevelError + 8 // 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",
|
LevelTrace: "trace",
|
||||||
LevelDebug: "debug",
|
LevelDebug: "debug",
|
||||||
LevelInfo: "info",
|
LevelInfo: "info",
|
||||||
|
LevelWarn: "warn",
|
||||||
LevelError: "error",
|
LevelError: "error",
|
||||||
LevelFatal: "fatal",
|
LevelFatal: "fatal",
|
||||||
LevelPrint: "print",
|
LevelPrint: "print",
|
||||||
|
@ -95,6 +97,7 @@ var Levels = map[string]slog.Level{
|
||||||
"trace": LevelTrace,
|
"trace": LevelTrace,
|
||||||
"debug": LevelDebug,
|
"debug": LevelDebug,
|
||||||
"info": LevelInfo,
|
"info": LevelInfo,
|
||||||
|
"warn": LevelWarn,
|
||||||
"error": LevelError,
|
"error": LevelError,
|
||||||
"fatal": LevelFatal,
|
"fatal": LevelFatal,
|
||||||
"print": LevelPrint,
|
"print": LevelPrint,
|
||||||
|
@ -207,6 +210,17 @@ func (l Log) Infox(msg string, err error, attrs ...slog.Attr) {
|
||||||
l.Logger.LogAttrs(noctx, LevelInfo, msg, attrs...)
|
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) {
|
func (l Log) Error(msg string, attrs ...slog.Attr) {
|
||||||
l.Logger.LogAttrs(noctx, LevelError, msg, attrs...)
|
l.Logger.LogAttrs(noctx, LevelError, msg, attrs...)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1343,7 +1343,7 @@ func prepareDynamicConfig(ctx context.Context, log mlog.Log, dynamicPath string,
|
||||||
if !ok {
|
if !ok {
|
||||||
addErrorf("could not find localpart %q to replace with address in destinations", lp)
|
addErrorf("could not find localpart %q to replace with address in destinations", lp)
|
||||||
} else {
|
} 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("localpart", lp),
|
||||||
slog.Any("address", addr),
|
slog.Any("address", addr),
|
||||||
slog.String("account", accName))
|
slog.String("account", accName))
|
||||||
|
|
|
@ -301,7 +301,7 @@ const config = async () => {
|
||||||
const loglevels = async () => {
|
const loglevels = async () => {
|
||||||
const loglevels = await api.LogLevels()
|
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
|
let form, fieldset, pkg, level
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue