Dima 76032b7ba4 Update logger 6 bulan lalu
..
email_writer.go 76032b7ba4 Update logger 6 bulan lalu
logger.go 76032b7ba4 Update logger 6 bulan lalu
logger_config.go 76032b7ba4 Update logger 6 bulan lalu
logger_ctx.go 491041bc01 Add logger 6 bulan lalu
readme.md 76032b7ba4 Update logger 6 bulan lalu

readme.md

Usage example

err := logger.Init(logger.NewConfig(
    logger.WithStdoutLogEnabled(true),
    logger.WithStdoutLogLevel(slog.LevelWarn),
    logger.WithFileLogEnabled(true),
    logger.WithFileLogLevel(slog.LevelError),
    logger.WithFileLogAddSource(true),
    logger.WithFilepath("./errors.log"),
))

if err != nil {
    // TODO
}

ctx := context.Background()

ctx = logger.With(ctx, "key1", "value1")

logger.ErrorKV(ctx, "error message", "key2", "value2")
// {"time":"2024-04-19T20:19:17.274684+00:00","level":"ERROR","msg":"error message","key2":"value2","key1":"value1"}