utility

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 2, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package utility provides utility functions and types for the application, such as logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

Logger is a wrapper around go-kit log.Logger that provides structured logging with different levels.

func NewLogger

func NewLogger(format LoggerFormat, debug bool) *Logger

NewLogger creates a new Logger with the specified format and debug level.

func (*Logger) Debug

func (l *Logger) Debug(keyvals ...any)

Debug logs a debug message with keyvals.

func (*Logger) Err

func (l *Logger) Err(err error, keyvals ...any)

Err logs an error type with additional keyvals.

func (*Logger) Error

func (l *Logger) Error(keyvals ...any)

Error logs an error message with keyvals.

func (*Logger) GetLogger

func (l *Logger) GetLogger() log.Logger

GetLogger returns the underlying go-kit log.Logger.

func (*Logger) Info

func (l *Logger) Info(keyvals ...any)

Info logs an info message with keyvals.

func (*Logger) Log

func (l *Logger) Log(keyvals ...any)

Log logs a message with keyvals.

func (*Logger) SetDebug

func (l *Logger) SetDebug(value bool) *Logger

SetDebug sets the debug level for the logger. If debug is true, debug messages will be logged.

func (*Logger) Warn

func (l *Logger) Warn(keyvals ...any)

Warn logs a warning message with keyvals.

func (*Logger) With

func (l *Logger) With(keyvals ...any) *Logger

With returns a new contextual logger with keyvals prepended to those passed to calls to Log. If logger is also a contextual logger created by With or WithPrefix, keyvals is appended to the existing context.

The returned Logger replaces all value elements (odd indexes) containing a Valuer with their generated value for each call to its Log method.

func (*Logger) WithPrefix

func (l *Logger) WithPrefix(keyvals ...any) *Logger

WithPrefix returns a new contextual logger with keyvals prepended to those passed to calls to Log. If logger is also a contextual logger created by With or WithPrefix, keyvals is prepended to the existing context.

The returned Logger replaces all value elements (odd indexes) containing a Valuer with their generated value for each call to its Log method.

type LoggerFormat

type LoggerFormat string

LoggerFormat represents the format of the logs.

const (
	// LogFormatJSON represents the JSON log format.
	LogFormatJSON LoggerFormat = "json"
	// LogFormatFmt represents the logfmt log format.
	LogFormatFmt LoggerFormat = "fmt"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL