Documentation ¶
Overview ¶
Package typelog is a slog modified for extra static type safety and extra boilerplating out of the box
Index ¶
- Constants
- Variables
- func CompL[T any, V any](objs []T, lambda func(x T) V) []V
- func GetCallingFile(level int) string
- func Group(name string, attrs ...slog.Attr) slog.Attr
- func IsMsgEnabled(current_level, msg_level LogLevel) bool
- func LevelToInt(level LogLevel) int
- func StructToMap(somestruct any) map[string]any
- func TurnMapToAttrs(params map[string]any) []slog.Attr
- func TurnStructToAttrs(somestruct any) []slog.Attr
- type LogAtrs
- type LogLevel
- type LogType
- func Actual(value any) LogType
- func Any(key string, value any) LogType
- func Args(value []string) LogType
- func Bool(key string, value bool) LogType
- func Bytes(key string, value []byte) LogType
- func Expected(value any) LogType
- func Float32(key string, value float32) LogType
- func Float64(key string, value float64) LogType
- func Int(key string, value int) LogType
- func Int64(key string, value int64) LogType
- func Items[T any](item_name string, value []T) LogType
- func Map(value map[string]any) LogType
- func NestedMap(key string, value map[string]any) LogType
- func NestedStruct(key string, value StructType) LogType
- func OptError(err error) LogType
- func Records[T any](value []T) LogType
- func String(key string, value string) LogType
- func Struct(value StructType) LogType
- func TestParam(value int) LogType
- func Time(key string, value time.Time) LogType
- type Logger
- func (l *Logger) CheckDebug(err error, msg string, opts ...LogType) bool
- func (l *Logger) CheckError(err error, msg string, opts ...LogType) bool
- func (l *Logger) CheckFatal(err error, msg string, opts ...LogType)
- func (l *Logger) CheckPanic(err error, msg string, opts ...LogType)
- func (l *Logger) CheckWarn(err error, msg string, opts ...LogType) bool
- func (l *Logger) Debug(msg string, opts ...LogType)
- func (l *Logger) Error(msg string, opts ...LogType)
- func (l *Logger) Fatal(msg string, opts ...LogType)
- func (l *Logger) GetName() string
- func (l *Logger) Info(msg string, opts ...LogType)
- func (l *Logger) Initialized() *Logger
- func (l *Logger) OverrideOption(options ...LoggerParam) *Logger
- func (l *Logger) Panic(msg string, opts ...LogType)
- func (l *Logger) Warn(msg string, opts ...LogType)
- func (l *Logger) WithFields(opts ...LogType) *Logger
- type LoggerParam
- type SlogAttr
- type StructType
- type TypelogEnvs
Constants ¶
View Source
const (
TOOL_NAME = "typelog"
)
Variables ¶
View Source
var RegisteredLoggers []*Logger
RegisteredLoggers leaves option for end applications to access all registered loggers and choosing their own log levels to override for them
Functions ¶
func GetCallingFile ¶
func IsMsgEnabled ¶
func LevelToInt ¶
func StructToMap ¶
func TurnStructToAttrs ¶
Types ¶
type LogType ¶
type LogType func(r *LogAtrs)
func NestedStruct ¶
func NestedStruct(key string, value StructType) LogType
func Struct ¶
func Struct(value StructType) LogType
type Logger ¶
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶
func NewLogger( name string, options ...LoggerParam, ) *Logger
func (*Logger) CheckDebug ¶
func (*Logger) CheckError ¶
func (*Logger) CheckFatal ¶
CheckFatal has shorter error output in comparison to CheckPanic
func (*Logger) Initialized ¶
func (*Logger) OverrideOption ¶
func (l *Logger) OverrideOption(options ...LoggerParam) *Logger
OverrideOption for overrides by external libraries
func (*Logger) WithFields ¶
type LoggerParam ¶
type LoggerParam func(r *Logger)
func WithFileShowing ¶
func WithFileShowing(state bool) LoggerParam
func WithIoWriter ¶ added in v0.6.0
func WithIoWriter(writer io.Writer) LoggerParam
func WithJsonFormat ¶
func WithJsonFormat(state bool) LoggerParam
func WithLogLevel ¶
func WithLogLevel(log_level_str LogLevel) LoggerParam
func WithLogLevelStr ¶
func WithLogLevelStr(log_level_str string) LoggerParam
type StructType ¶ added in v0.3.3
type StructType = any
Source Files ¶
Click to show internal directories.
Click to hide internal directories.