llog

package module
v0.0.0-...-e8f9f86 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2020 License: MIT Imports: 5 Imported by: 2

README

LLog

GoDoc Go Report Card MIT licensed

LLog - Monolog implementation in Go.

GoDoc

Download & Installs

go get github.com/syyongx/llog

Usage

package main

import (
	"github.com/syyongx/llog"
	"github.com/syyongx/llog/handler"
	"github.com/syyongx/llog/formatter"
	"github.com/syyongx/llog/types"
)

func main() 
	// New logger{
	logger := NewLogger("my-log")

	file := handler.NewFile("/tmp/llog/go.log", 0664, types.WARNING, true)
	buf := handler.NewBuffer(file, 1, types.WARNING, true)
	f := formatter.NewLine("%Datetime% [%LevelName%] [%Channel%] %Message%\n", time.RFC3339)
	file.SetFormatter(f)

	// push handler
	logger.PushHandler(buf)

	// add log
	logger.Warning("xxx")

	// close and write
	buf.Close()
}

LICENSE

LLog source code is licensed under the MIT Licence.

Documentation

Overview

Package llog is a log tool library. php Monolog implementation in Go. Source code and other details for the project are available at GitHub:

https://github.com/syyongx/llog

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

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

Logger logger struct

func NewLogger

func NewLogger(name string) *Logger

NewLogger new logger

func (*Logger) AddRecord

func (l *Logger) AddRecord(level int, message string) bool

AddRecord Adds a log record.

func (*Logger) Alert

func (l *Logger) Alert(message interface{})

Alert Adds a log record at the ALERT level.

func (*Logger) Debug

func (l *Logger) Debug(message interface{})

Debug Detailed debug information.

func (*Logger) Emergency

func (l *Logger) Emergency(message interface{})

Emergency System is unusable.

func (*Logger) Error

func (l *Logger) Error(message interface{})

Error Runtime errors that do not require immediate action but should typically be logged and monitored.

func (*Logger) GetHandlers

func (l *Logger) GetHandlers() []types.IHandler

GetHandlers Get handlers

func (*Logger) GetLevelByName

func (l *Logger) GetLevelByName(levelName string) (int, error)

GetLevelByName Gets the value by the logging level name.

func (*Logger) GetLevelName

func (l *Logger) GetLevelName(level int) (string, error)

GetLevelName Gets the name of the logging level.

func (*Logger) GetLevels

func (l *Logger) GetLevels() map[int]string

GetLevels Gets all supported logging levels.

func (*Logger) GetName

func (l *Logger) GetName() string

GetName get name

func (*Logger) GetProcessor

func (l *Logger) GetProcessor() []types.Processor

GetProcessor Get processors

func (*Logger) GetTimezone

func (l *Logger) GetTimezone(tz string) string

GetTimezone Get timezone

func (*Logger) Info

func (l *Logger) Info(message interface{})

Info Interesting events. Example: User logs in, SQL logs.

func (*Logger) IsHandling

func (l *Logger) IsHandling(level int) bool

IsHandling Checks whether the Logger has a handler that listens on the given level.

func (*Logger) Log

func (l *Logger) Log(level int, message string)

Log Logs with an arbitrary level.

func (*Logger) Notice

func (l *Logger) Notice(message interface{})

Notice Normal but significant events.

func (*Logger) PopHandler

func (l *Logger) PopHandler() (types.IHandler, error)

PopHandler Pops a handler from the stack.

func (*Logger) PopProcessor

func (l *Logger) PopProcessor() (types.Processor, error)

PopProcessor Pops a processor from the stack.

func (*Logger) PushHandler

func (l *Logger) PushHandler(h types.IHandler)

PushHandler pushes a handler on to the stack.

func (*Logger) PushProcessor

func (l *Logger) PushProcessor(p types.Processor)

PushProcessor Pushes a processor on to the stack.

func (*Logger) SetHandlers

func (l *Logger) SetHandlers(handlers []types.IHandler)

SetHandlers Set handlers, replacing all existing ones.

func (*Logger) SetTimezone

func (l *Logger) SetTimezone(tz string)

SetTimezone Set the timezone to be used for the timestamp of log records.

func (*Logger) String

func (l *Logger) String(data interface{}) string

String Stringify

func (*Logger) Warning

func (l *Logger) Warning(message interface{})

Warning Exceptional occurrences that are not errors. Example: Use of deprecated APIs, poor use of an API, undesirable things that are not necessarily wrong.

type Registry

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

Registry struct

func NewRegistry

func NewRegistry() *Registry

NewRegistry new registry

func (*Registry) AddLogger

func (r *Registry) AddLogger(logger *Logger, name string, overwrite bool) error

AddLogger Adds new logging channel to the registry

func (*Registry) Clear

func (r *Registry) Clear()

Clear Clears the registry

func (*Registry) GetLogger

func (r *Registry) GetLogger(name string) (*Logger, error)

GetLogger Gets Logger instance from the registry

func (*Registry) HasLogger

func (r *Registry) HasLogger(name string) bool

HasLogger Checks if such logging channel exists by name or instance

func (*Registry) RemoveLogger

func (r *Registry) RemoveLogger(name string)

RemoveLogger Removes instance from registry by name or instance

Directories

Path Synopsis
Package handler provides some commonly used handlers。
Package handler provides some commonly used handlers。

Jump to

Keyboard shortcuts

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