Files
iptvc/app/logger/logger.go
AnthonyAxenov d15d4f47b6
All checks were successful
release / release (push) Successful in 5m47s
Initial commit
2025-05-06 10:45:37 +08:00

42 lines
873 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Copyright (c) 2025, Антон Аксенов
* This file is part of iptvc project
* MIT License: https://git.axenov.dev/IPTV/iptvc/src/branch/master/LICENSE
*/
package logger
import (
"io"
"log"
"log/slog"
"os"
)
// Init инициализирует стандартный логгер
func Init(quiet bool) {
log.SetOutput(os.Stdout)
if quiet {
log.SetOutput(io.Discard)
}
}
// InitSlog инициализирует продвинутый логгер
// TODO пока непонятно что с этим делать
func InitSlog(quiet bool, debug bool) {
writer := os.Stdout
if quiet {
writer = nil
}
level := slog.LevelInfo
if debug {
level = slog.LevelDebug
}
options := slog.HandlerOptions{Level: level, AddSource: false}
handler := slog.NewTextHandler(writer, &options)
logger := slog.New(handler)
slog.SetDefault(logger)
}