Documentation ¶
Index ¶
- func ApplyConfig(cfg *Config) error
- func CurrentPackageFileName() string
- func GetNamedLogger(name string) *logger
- func GetObjectLogger(obj interface{}) *logger
- func GetPackageLogger() *logger
- func GetTypeLogger(t reflect.Type) *logger
- func RegisterCustomLoggerTarget(name string, logger CustomTarget) error
- func ReloadConfig() error
- type Config
- type CustomTarget
- type CustomTargetWithError
- type Logger
- type Manager
- func (m *Manager) ApplyConfig(cfg *Config) error
- func (m *Manager) GetNamedLogger(name string) *logger
- func (m *Manager) GetObjectLogger(obj interface{}) *logger
- func (m *Manager) GetPackageLogger() *logger
- func (m *Manager) GetTypeLogger(t reflect.Type) *logger
- func (m *Manager) ReloadConfig() error
- type RouterConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ApplyConfig ¶
func CurrentPackageFileName ¶
func CurrentPackageFileName() string
CurrentPackageFileName returns the name of the current file in the current package
For example calling it in this file would return "github.com/jerejones/jlog/namers.go"
func GetNamedLogger ¶
func GetNamedLogger(name string) *logger
func GetObjectLogger ¶
func GetObjectLogger(obj interface{}) *logger
func GetPackageLogger ¶
func GetPackageLogger() *logger
func GetTypeLogger ¶
func RegisterCustomLoggerTarget ¶
func RegisterCustomLoggerTarget(name string, logger CustomTarget) error
RegisterCustomLoggerTarget allows a custom target to be used in your config
name is the value that will go in the Type field of the target config
func ReloadConfig ¶ added in v1.0.2
func ReloadConfig() error
Types ¶
type Config ¶
type Config struct { AutoReload bool Routes []RouterConfig Targets []target.Config // contains filtered or unexported fields }
Config describes how loggers will be setup
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig returns a new copy of the default config The default config is equivalent to the following json:
{ "autoreload": true, "routes": [ { "name": "*", "writeto": "console", "minlevel": "info" } ], "targets": [ { "name": "console", "type": "console", "layout": "${datetime} [${level}] ${message}" } ] }
func LoadConfig ¶
type CustomTarget ¶
type CustomTarget interface {
Write(string)
}
CustomTarget is the interface that every custom target has to implement.
Write will be called with the rendered log entry Note that string will not end with a line feed
type CustomTargetWithError ¶
type CustomTargetWithError interface { CustomTarget WriteError(string) }
CustomTargetWithError is the interface that custom targets may implement so that WARN and ERROR level log entries may be handled differently
Note that string will not end with a line feed
type Logger ¶
type Logger interface { Error(v ...interface{}) error Warning(v ...interface{}) error Info(v ...interface{}) error Debug(v ...interface{}) error Errorf(format string, a ...interface{}) error Warningf(format string, a ...interface{}) error Infof(format string, a ...interface{}) error Debugf(format string, a ...interface{}) error }
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func NewManager ¶
func (*Manager) ApplyConfig ¶
func (*Manager) GetNamedLogger ¶
func (*Manager) GetObjectLogger ¶
func (m *Manager) GetObjectLogger(obj interface{}) *logger
func (*Manager) GetPackageLogger ¶
func (m *Manager) GetPackageLogger() *logger