LoggerTerminal Output
Custom Notice Level
The logger includes a custom `LevelNotice` log level designed for important operational messages that should remain highly visible in terminal output.
LevelNotice is positioned between INFO and WARN and is intended for events such as:
- application startup
- graceful shutdown
- deployment events
- configuration loading
- maintenance notifications
- important business operations
Example usage:
package main
import (
"log/slog"
"github.com/netlifeguru/logger"
)
func main() {
closer, err := logger.Init(logger.Config{
TerminalOutput: true,
ConsoleMinLevel: slog.LevelDebug,
})
if err != nil {
slog.Error(err.Error())
}
defer closer.Close()
logger.Notice("server started")
logger.Notice("configuration loaded")
}Example terminal output:
2026-05-11 12:45:43 server started
2026-05-11 12:45:43 configuration loadedLevelNotice is useful when standard informational logs are too noisy but warnings or errors would incorrectly imply a problem state.
Context-aware variants are also supported:
logger.NoticeContext(ctx, "background worker initialized")Full example:
package main
import (
"context"
"log/slog"
"github.com/netlifeguru/logger"
)
func main() {
closer, err := logger.Init(logger.Config{
Dir: "./logs",
TerminalOutput: true,
})
if err != nil {
slog.Error(err.Error())
}
defer closer.Close()
ctx := context.Background()
logger.NoticeContext(ctx, "important event", "order_id", 1)
}
Internally, the notice level integrates directly with the logger’s structured logging pipeline and behaves like any other slog level.