Documentation
¶
Index ¶
- func CloseOrIgnore(closer io.Closer)
- func CloseOrLog(closer io.Closer)
- func CloseOrPanic(closer io.Closer)
- func CloseOrPrintLn(closer io.Closer)
- func CyclicOverwritingFilesHandler(folder, fileNamePrefix string, maxFileCapacity uint32, maxFilesInFolder int) io.Writer
- func FileByFormatHandler(folder string, maxFilesInFolder int, fileNameGenerator func() string) io.Writer
- func JsonDecode(r io.Reader, v any) error
- func JsonDecodeAndClose(r io.ReadCloser, v any) (err error)
- func JsonDecodeAndCloseEx(r io.ReadCloser, v any) (raw []byte, err error)
- func JsonDecodeEx(r io.Reader, v any) ([]byte, error)
- func JsonEncode(w io.Writer, v any, indent ...int) error
- func JsonEncodeAndClose(w io.WriteCloser, v any, indent ...int) (err error)
- func JsonEncodeAndCloseEx(w io.WriteCloser, v any, indent ...int) (raw []byte, err error)
- func JsonEncodeEx(w io.Writer, v any, indent ...int) ([]byte, error)
- func NewHttpPayloadHandler(logger *Logger, level LogLevel, nextFunc http.HandlerFunc) (http.HandlerFunc, error)
- func PrintHandler() io.Writer
- func SilenceHandler() io.Writer
- func TelegramHandler(botToken, chatID, fileName string, labels ...string) io.Writer
- type HookID
- type HttpError
- type LogLevel
- type Logger
- func (l *Logger) Fatal(level LogLevel, args ...any)
- func (l *Logger) Fatalf(level LogLevel, format string, args ...any)
- func (l *Logger) Hook(writer io.Writer, level LogLevel, additional ...LogLevel) HookID
- func (l *Logger) JoinAs(logLevel LogLevel, outputs ...func(w io.Writer))
- func (l *Logger) Print(level LogLevel, args ...any)
- func (l *Logger) Printf(level LogLevel, format string, args ...any)
- func (l *Logger) SetMinLevel(level LogLevel)
- func (l *Logger) Unhook(id HookID)
- func (l *Logger) Write(message []byte) (int, error)
- func (l *Logger) WriteLog(level LogLevel, message []byte) (int, error)
- func (l *Logger) WriterAs(level LogLevel) io.Writer
- type TraceError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CloseOrIgnore ¶
CloseOrIgnore closes the closer and ignores the error if there is one.
func CloseOrLog ¶
CloseOrLog closes the closer and logs the error if there is one.
func CloseOrPanic ¶
CloseOrPanic closes the closer and panics if there is an error.
func CloseOrPrintLn ¶
CloseOrPrintLn closes the closer and prints the error if there is one.
func CyclicOverwritingFilesHandler ¶
func CyclicOverwritingFilesHandler(folder, fileNamePrefix string, maxFileCapacity uint32, maxFilesInFolder int) io.Writer
CyclicOverwritingFilesHandler save messages to files by number. The file name is generated by fileNamePrefix and index. The folder is the directory where the files are saved. The maxFileCapacity is the maximum size of the file in bytes. The maxFilesInFolder is the maximum number of files in the folder.
func FileByFormatHandler ¶
func FileByFormatHandler(folder string, maxFilesInFolder int, fileNameGenerator func() string) io.Writer
FileByFormatHandler save messages to files by format. The file name is generated by fileNameGenerator. The folder is the directory where the files are saved. The maxFilesInFolder is the maximum number of files in the folder.
func JsonDecodeAndClose ¶
func JsonDecodeAndClose(r io.ReadCloser, v any) (err error)
func JsonDecodeAndCloseEx ¶
func JsonDecodeAndCloseEx(r io.ReadCloser, v any) (raw []byte, err error)
func JsonEncodeAndClose ¶
func JsonEncodeAndClose(w io.WriteCloser, v any, indent ...int) (err error)
func JsonEncodeAndCloseEx ¶
func NewHttpPayloadHandler ¶
func NewHttpPayloadHandler(logger *Logger, level LogLevel, nextFunc http.HandlerFunc) (http.HandlerFunc, error)
NewHttpPayloadHandler - create new http middleware handler. This middleware logs the request and response payloads. The log is written to the logger.
func SilenceHandler ¶
SilenceHandler does nothing that is ignores any messages and returns the length of the message without any errors
Types ¶
type HttpError ¶
HttpError is an error that provides an HTTP status code.
func NewHttpError ¶
NewHttpError creates a new HttpError with the given status code.
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
Logger is describing the logger structure and its methods
func NewLogger ¶
NewLogger creates a new logger with the given minimum log level and handlers If no handlers are provided, a default print handler is added
func (*Logger) SetMinLevel ¶
SetMinLevel sets the minimum log level
type TraceError ¶
TraceError is an error that provides a stack trace.
func NewTraceError ¶
func NewTraceError() TraceError
NewTraceError creates a new TraceError with the current stack trace.