jlog

package module
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2017 License: MIT Imports: 15 Imported by: 0

README

jLOG

Build Status Coverage Status License GoDoc

Love nLog and Go?

Welcome to nLog for Go.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyConfig

func ApplyConfig(cfg *Config) error

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 GetTypeLogger(t reflect.Type) *logger

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

func LoadConfig(filename string) *Config

func UnmarshalConfig

func UnmarshalConfig(rdr io.Reader) (*Config, error)

UnmarshalConfig will unmarshal a config from an io.Reader in json format

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 NewManager(cfg *Config) (*Manager, error)

func (*Manager) ApplyConfig

func (m *Manager) ApplyConfig(cfg *Config) error

func (*Manager) GetNamedLogger

func (m *Manager) GetNamedLogger(name string) *logger

func (*Manager) GetObjectLogger

func (m *Manager) GetObjectLogger(obj interface{}) *logger

func (*Manager) GetPackageLogger

func (m *Manager) GetPackageLogger() *logger

func (*Manager) GetTypeLogger

func (m *Manager) GetTypeLogger(t reflect.Type) *logger

func (*Manager) ReloadConfig added in v1.0.2

func (m *Manager) ReloadConfig() error

type RouterConfig

type RouterConfig struct {
	Name     string
	WriteTo  string
	MinLevel string
	MaxLevel string
}

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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