logo

package module
v0.0.0-...-192d065 Latest Latest
Warning

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

Go to latest
Published: May 2, 2014 License: GPL-2.0 Imports: 5 Imported by: 1

README

A lightweight log in golang with the capability to extend as standard log package.

What's an idea log package? In my view, the idea log package should be:

  • Object free : No any burden to to create object or initialize the logger;
  • Compact with the standard log interface, so that any one with io.Writer interface can be leveraged;
  • Level based : So that end user can customize the output at a certain level;
  • Multiple loggers integrated;
  • Simple enough : Have no chance to create bug;

logo is a implementation base on this philosophy; You can use it as showing below:

import (
	"bytes"
	log "github.com/robinmin/logo"
)

func main() {
	// you can just use the log package like, the system will output the log to stdout by default
	log.Debug("Balabala,bala......")

	// If you have a customized logger, you can use it like the following. The system will output
	//  the log into both stdout and buf
	var buf = bytes.NewBuffer(nil)
	log.AddLogger("buffer", buf, log.ALL)
	defer log.ReleaseLogger("buffer")
	str := "Buffer one"
	log.Debug(str)
}

Documentation

Overview

Package logo provides global logging methods so that multiple packages may log to a single application-defined stream.

If any logging method is called before AddLogger/ReleaseLogger is called, nothing will be outputted.

Index

Constants

View Source
const (
	CRITICAL = 1 << iota
	ERROR
	WARNING
	NOTICE
	INFO
	DEBUG

	ALL int = CRITICAL | ERROR | WARNING | NOTICE | INFO | DEBUG
)

Variables

This section is empty.

Functions

func AddLogger

func AddLogger(module string, w io.Writer, levelMask int) *log.Logger

func Critical

func Critical(format string, v ...interface{})

func Debug

func Debug(format string, v ...interface{})

func Error

func Error(format string, v ...interface{})

func GetLogger

func GetLogger(module string) *log.Logger

func Info

func Info(format string, v ...interface{})

func Notice

func Notice(format string, v ...interface{})

func ReleaseLogger

func ReleaseLogger(module string) bool

func Warn

func Warn(format string, v ...interface{})

Types

type LevelBasedLogger

type LevelBasedLogger struct {
	Module    string
	Logger    *log.Logger
	LevelMask int
}

Jump to

Keyboard shortcuts

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