mirror of
https://git.vectorsigma.ru/public/photoview.git
synced 2026-08-03 18:19:11 +00:00
* Add log package. Update worker with new log package. * Add init error to worker. * Init workers when binary launching. * Add tests to cover different errors.
58 lines
1.5 KiB
Go
58 lines
1.5 KiB
Go
package log
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
)
|
|
|
|
var defaultLogger *slog.Logger
|
|
|
|
func init() {
|
|
defaultLogger = slog.Default()
|
|
}
|
|
|
|
// Debug calls [Logger.Debug] on the default logger.
|
|
func Debug(msg string, args ...any) {
|
|
defaultLogger.Debug(msg, args...)
|
|
}
|
|
|
|
// DebugContext calls [Logger.DebugContext] on the default logger.
|
|
func DebugContext(ctx context.Context, msg string, args ...any) {
|
|
defaultLogger.DebugContext(ctx, msg, args...)
|
|
}
|
|
|
|
// Info calls [Logger.Info] on the default logger.
|
|
func Info(msg string, args ...any) {
|
|
defaultLogger.Info(msg, args...)
|
|
}
|
|
|
|
// InfoContext calls [Logger.InfoContext] on the default logger.
|
|
func InfoContext(ctx context.Context, msg string, args ...any) {
|
|
defaultLogger.InfoContext(ctx, msg, args...)
|
|
}
|
|
|
|
// Warn calls [Logger.Warn] on the default logger.
|
|
func Warn(msg string, args ...any) {
|
|
defaultLogger.Warn(msg, args...)
|
|
}
|
|
|
|
// WarnContext calls [Logger.WarnContext] on the default logger.
|
|
func WarnContext(ctx context.Context, msg string, args ...any) {
|
|
defaultLogger.WarnContext(ctx, msg, args...)
|
|
}
|
|
|
|
// Error calls [Logger.Error] on the default logger.
|
|
func Error(msg string, args ...any) {
|
|
defaultLogger.Error(msg, args...)
|
|
}
|
|
|
|
// ErrorContext calls [Logger.ErrorContext] on the default logger.
|
|
func ErrorContext(ctx context.Context, msg string, args ...any) {
|
|
defaultLogger.ErrorContext(ctx, msg, args...)
|
|
}
|
|
|
|
// With calls [Logger.With] on the default logger.
|
|
func With(args ...any) *slog.Logger {
|
|
return defaultLogger.With(args...)
|
|
}
|