utils

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Logger *slog.Logger

Logger is the global logger instance.

Functions

func Contains added in v1.2.0

func Contains(s, substr string) bool

Contains checks if a string contains a substring (case-sensitive).

func Debug added in v0.28.0

func Debug(msg string, args ...any)

Debug logs a debug message.

func Error added in v0.28.0

func Error(msg string, args ...any)

Error logs an error message.

func FormatBytes

func FormatBytes(bytes int64) string

FormatBytes converts a byte count to a human-readable string.

func FormatDuration

func FormatDuration(ms int64) string

FormatDuration converts milliseconds to a human-readable duration string.

func Info added in v0.28.0

func Info(msg string, args ...any)

Info logs an info message.

func InitLogger

func InitLogger(logPath string, level LogLevel) error

InitLogger initializes the global logger.

func SetVerbose added in v1.2.0

func SetVerbose()

SetVerbose enables debug logging.

func ShortenPath

func ShortenPath(path string, maxLen int) string

ShortenPath truncates a path to fit within maxLen characters. It preserves the end of the path and adds "..." prefix if truncated.

func Warn

func Warn(msg string, args ...any)

Warn logs a warning message.

func With added in v1.2.0

func With(args ...any) *slog.Logger

With returns a logger with additional context.

Types

type LogLevel

type LogLevel string

LogLevel represents logging severity.

const (
	LevelDebug LogLevel = "debug"
	LevelInfo  LogLevel = "info"
	LevelWarn  LogLevel = "warn"
	LevelError LogLevel = "error"
)

Jump to

Keyboard shortcuts

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