logger

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:03:15 * @FilePath: \go-sqlbuilder\constant\error.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:05:16 * @FilePath: \go-sqlbuilder\logger\interface.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

* @Author: kamalyes 501893067@qq.com * @Date: 2025-11-11 00:00:00 * @LastEditors: kamalyes 501893067@qq.com * @LastEditTime: 2025-11-13 11:05:59 * @FilePath: \go-sqlbuilder\logger\noop.go * @Description: * * Copyright (c) 2025 by kamalyes, All Rights Reserved.

Index

Constants

View Source
const (
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
	LevelFatal = "fatal"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type DefaultLoggerFactory

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

func NewLoggerFactory

func NewLoggerFactory(creator LoggerCreator) *DefaultLoggerFactory

func (*DefaultLoggerFactory) CreateLogger

func (f *DefaultLoggerFactory) CreateLogger(name string) Logger

func (*DefaultLoggerFactory) GetDefaultLogger

func (f *DefaultLoggerFactory) GetDefaultLogger() Logger

func (*DefaultLoggerFactory) SetDefaultLogger

func (f *DefaultLoggerFactory) SetDefaultLogger(logger Logger)

type GoLoggerAdapter

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

func (*GoLoggerAdapter) Debug

func (gl *GoLoggerAdapter) Debug(msg string, fields ...interface{})

func (*GoLoggerAdapter) Debugf

func (gl *GoLoggerAdapter) Debugf(format string, args ...interface{})

func (*GoLoggerAdapter) Error

func (gl *GoLoggerAdapter) Error(msg string, fields ...interface{})

func (*GoLoggerAdapter) Errorf

func (gl *GoLoggerAdapter) Errorf(format string, args ...interface{})

func (*GoLoggerAdapter) Fatal

func (gl *GoLoggerAdapter) Fatal(msg string, fields ...interface{})

func (*GoLoggerAdapter) Fatalf

func (gl *GoLoggerAdapter) Fatalf(format string, args ...interface{})

func (*GoLoggerAdapter) GetLevel

func (gl *GoLoggerAdapter) GetLevel() string

func (*GoLoggerAdapter) Info

func (gl *GoLoggerAdapter) Info(msg string, fields ...interface{})

func (*GoLoggerAdapter) Infof

func (gl *GoLoggerAdapter) Infof(format string, args ...interface{})

func (*GoLoggerAdapter) LogDuration

func (gl *GoLoggerAdapter) LogDuration(operation string, duration interface{}, fields ...interface{})

func (*GoLoggerAdapter) SetLevel

func (gl *GoLoggerAdapter) SetLevel(level string) Logger

func (*GoLoggerAdapter) StartTimer

func (gl *GoLoggerAdapter) StartTimer() Timer

func (*GoLoggerAdapter) Warn

func (gl *GoLoggerAdapter) Warn(msg string, fields ...interface{})

func (*GoLoggerAdapter) Warnf

func (gl *GoLoggerAdapter) Warnf(format string, args ...interface{})

func (*GoLoggerAdapter) With

func (gl *GoLoggerAdapter) With(key string, value interface{}) Logger

func (*GoLoggerAdapter) WithContext

func (gl *GoLoggerAdapter) WithContext(ctx interface{}) Logger

type Logger

type Logger interface {
	Debug(msg string, fields ...interface{})
	Info(msg string, fields ...interface{})
	Warn(msg string, fields ...interface{})
	Error(msg string, fields ...interface{})
	Fatal(msg string, fields ...interface{})

	// Printf风格的方法
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warnf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})

	With(key string, value interface{}) Logger
	WithContext(ctx interface{}) Logger

	SetLevel(level string) Logger
	GetLevel() string

	StartTimer() Timer
	LogDuration(operation string, duration interface{}, fields ...interface{})
}

func NewGoLogger

func NewGoLogger(name string) Logger

func NewNoOpLogger

func NewNoOpLogger() Logger

type LoggerCreator

type LoggerCreator func(name string) Logger

type LoggerFactory

type LoggerFactory interface {
	CreateLogger(name string) Logger
	SetDefaultLogger(logger Logger)
	GetDefaultLogger() Logger
}

type NoOpLogger

type NoOpLogger struct{}

func (*NoOpLogger) Debug

func (n *NoOpLogger) Debug(msg string, fields ...interface{})

func (*NoOpLogger) Debugf

func (n *NoOpLogger) Debugf(format string, args ...interface{})

func (*NoOpLogger) Error

func (n *NoOpLogger) Error(msg string, fields ...interface{})

func (*NoOpLogger) Errorf

func (n *NoOpLogger) Errorf(format string, args ...interface{})

func (*NoOpLogger) Fatal

func (n *NoOpLogger) Fatal(msg string, fields ...interface{})

func (*NoOpLogger) Fatalf

func (n *NoOpLogger) Fatalf(format string, args ...interface{})

func (*NoOpLogger) GetLevel

func (n *NoOpLogger) GetLevel() string

func (*NoOpLogger) Info

func (n *NoOpLogger) Info(msg string, fields ...interface{})

func (*NoOpLogger) Infof

func (n *NoOpLogger) Infof(format string, args ...interface{})

func (*NoOpLogger) LogDuration

func (n *NoOpLogger) LogDuration(operation string, duration interface{}, fields ...interface{})

func (*NoOpLogger) SetLevel

func (n *NoOpLogger) SetLevel(level string) Logger

func (*NoOpLogger) StartTimer

func (n *NoOpLogger) StartTimer() Timer

func (*NoOpLogger) Warn

func (n *NoOpLogger) Warn(msg string, fields ...interface{})

func (*NoOpLogger) Warnf

func (n *NoOpLogger) Warnf(format string, args ...interface{})

func (*NoOpLogger) With

func (n *NoOpLogger) With(key string, value interface{}) Logger

func (*NoOpLogger) WithContext

func (n *NoOpLogger) WithContext(ctx interface{}) Logger

type Timer

type Timer interface {
	Stop()
	Duration() time.Duration
}

Jump to

Keyboard shortcuts

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