log

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2020 License: MIT Imports: 8 Imported by: 0

README

Log library

Simple fast and low resource consuming library for writing logs into console, file and syslog

Usage example

package main

import "github.com/aiseeq/log"

func main() {
	log.SetConsoleLevel(log.L_debug)
	log.InitFile("log.txt", log.L_info)
	log.InitSyslog("AppName", log.L_warning)
	log.Info("AppName v1.0.0") 
}

Documentation

Overview

Package log provides simple logging to console, file and syslog

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Alert

func Alert(args ...interface{})

func Alertf

func Alertf(pattern string, args ...interface{})

func CaptureStdLog

func CaptureStdLog()

CaptureStdLog does what the name says. It means that any message sent to standard logger will be parsed via Write

func Critical

func Critical(args ...interface{})

func Criticalf

func Criticalf(pattern string, args ...interface{})

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(pattern string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(pattern string, args ...interface{})

func Fatal

func Fatal(args ...interface{})

Fatal outputs message and terminates application

func Fatalf

func Fatalf(pattern string, args ...interface{})

Fatalf outputs formatted message and terminates application

func Info

func Info(args ...interface{})

func Infof

func Infof(pattern string, args ...interface{})

func InitFile

func InitFile(file string, level Level)

InitFile should be called before writing messages to a local file

func InitSyslog

func InitSyslog(tag string, level Level) error

InitSyslog should be called before sending messages to Syslog

func Notice

func Notice(args ...interface{})

func Noticef

func Noticef(pattern string, args ...interface{})

func RestoreStdLog

func RestoreStdLog()

RestoreStdLog restores standard logger. Any message to it will be again sent to Stdout

func SetConsoleLevel

func SetConsoleLevel(level Level)

SetConsoleLevel sets log level which will be written into stdout

func SetMaxMessagesPerSecond

func SetMaxMessagesPerSecond(m int)

SetMaxMessagesPerSecond sets limit for messages per seconds. All messages above the limit will be discarded Set m = 0 to turn off the limit (default)

func SetSyslogLevel

func SetSyslogLevel(level Level)

SetSyslogLevel can be used to change Syslog messages level filter

func Warning

func Warning(args ...interface{})

func Warningf

func Warningf(pattern string, args ...interface{})

Types

type Level

type Level uint8
const (
	L_fatal Level = iota
	L_alert
	L_critical
	L_error
	L_warning
	L_notice
	L_info
	L_debug
)

func (Level) String

func (l Level) String() string

String returns string representation of Level

Jump to

Keyboard shortcuts

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