logo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2020 License: MIT Imports: 1 Imported by: 1

README

GoDoc Build Status Go Report Card MIT license

What is this?

A simple logging library.

Usage

In your library:
var Log = logo.New(logo.INFO, nil)

func Hello(){
    Log.I("hello")
    fmt.Println("world")
}
In your app:
  1. No settings required!
func main(){
    lib.Hello()
}
// [INFO] hello
// world
  1. You can set the minimum log level to display.
  • DEBUG < INFO < WARNING < ERROR
func main(){
    lib.Log.Level = Logo.ERROR
    lib.Hello()
}
// world
  1. You can also set a custom label for each log level.
func main(){
    lib.Log.LogMessageMap[Logo.INFO] = "[情報] "
    lib.Hello()
}
// [情報] hello
// world

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultLogMessageMap = map[LogLevel]string{DEBUG: "[DEBUG] ", INFO: "[INFO] ", WARNING: "[WARNING] ", ERROR: "[ERROR] "}

DefaultLogMessageMap maps LogLevel to logging strings in English.

Functions

This section is empty.

Types

type LogLevel

type LogLevel uint8

LogLevel represents log levels.

const (
	// DEBUG represents debug messages.
	DEBUG LogLevel = 0
	// INFO represents info messages.
	INFO LogLevel = 1
	// WARNING represents warning messages.
	WARNING LogLevel = 2
	// ERROR represents error messages.
	ERROR LogLevel = 3
)
type Logo struct {
	// Logger is the *log.Logger used for the Logo. The default is log.Printf (log.std).
	Logger *log.Logger
	// Level determines the lowest log level to display.
	Level LogLevel
	// LogMessageMap maps LogLevel to logging strings.
	LogMessageMap map[LogLevel]string
}

Logo represents the Logo logger.

func New

func New(level LogLevel, logger *log.Logger) *Logo

New initializes a Logo.

func (*Logo) D

func (l *Logo) D(format string, v ...interface{})

D logs a debug message.

func (*Logo) E

func (l *Logo) E(format string, v ...interface{})

E logs an error message.

func (*Logo) I

func (l *Logo) I(format string, v ...interface{})

I logs an info message.

func (*Logo) W

func (l *Logo) W(format string, v ...interface{})

W logs a warning message.

Directories

Path Synopsis
examples
logging command

Jump to

Keyboard shortcuts

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