logif

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2020 License: BSD-3-Clause Imports: 2 Imported by: 3 modules, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

go-logif

Golang: The abstract interface of a log output, and the wrapper of a standard "log" package.

  1. Golang standard (Print/Fatal/Panic)
  2. "Print" with message level (Debug/Info/Warn/Error)

Usage

package main

import "github.com/shimt/go-logif/gologif"

func main() {
    l := gologif.New(os.Stderr, "", gologif.LstdFlags)
	l.SetOutputLevel(gologif.DEBUG)
	l.Print("message")
	l.Debug("debug message")
	l.Info("info message")
	l.Warn("warn message")
	l.Error("error message")
    // Output:
    // 2020/03/22 14:06:21 message
    // 2020/03/22 14:06:21 [DEBUG] debug message
    // 2020/03/22 14:06:21 [INFO] info message
    // 2020/03/22 14:06:21 [WARN] warn message
    // 2020/03/22 14:06:21 [ERROR] error message
}

Documentation

Overview

Package logif is logging interface

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LeveledLogger

type LeveledLogger interface {
	// Debug write message(level=DEBUG) to the logger.
	// Arguments are handled in the manner of fmt.Print.
	Debug(v ...interface{})
	// Debugf write message(level=DEBUG) to the logger.
	// Arguments are handled in the manner of fmt.Printf.
	Debugf(format string, v ...interface{})
	// Debugln write message(level=DEBUG) to the logger.
	// Arguments are handled in the manner of fmt.Println.
	Debugln(v ...interface{})

	// Info write message(level=INFO) to the logger.
	// Arguments are handled in the manner of fmt.Print.
	Info(v ...interface{})
	// Infof write message(level=INFO) to the logger.
	// Arguments are handled in the manner of fmt.Printf.
	Infof(format string, v ...interface{})
	// Infoln write message(level=INFO) to the logger.
	// Arguments are handled in the manner of fmt.Println.
	Infoln(v ...interface{})

	// Warn write message(level=WARN) to the logger.
	// Arguments are handled in the manner of fmt.Print.
	Warn(v ...interface{})
	// Warnf write message(level=WARN) to the logger.
	// Arguments are handled in the manner of fmt.Printf.
	Warnf(format string, v ...interface{})
	// Warnln write message(level=WARN) to the logger.
	// Arguments are handled in the manner of fmt.Println.
	Warnln(v ...interface{})

	// Error write message(level=ERROR) to the logger.
	// Arguments are handled in the manner of fmt.Print.
	Error(v ...interface{})
	// Errorf write message(level=ERROR) to the logger.
	// Arguments are handled in the manner of fmt.Printf.
	Errorf(format string, v ...interface{})
	// Errorln write message(level=ERROR) to the logger.
	// Arguments are handled in the manner of fmt.Println.
	Errorln(v ...interface{})
}

LeveledLogger leveld logging interface

type LeveledLoggerModifier

type LeveledLoggerModifier interface {
	// SetOutputLevel set output level
	SetOutputLevel(l LogLevel)

	// OutputLevel set output level
	OutputLevel() LogLevel
}

LeveledLoggerModifier leveld logging modifier interface

type LogLevel

type LogLevel int32

LogLevel importance of the message.

importance becomes large in following order.

1) DEBUG 2) INFO 3) WARN 4) ERROR

const (
	// DEBUG debug message
	DEBUG LogLevel = iota
	// MINLEVEL minimum level
	MINLEVEL LogLevel = iota - 1
	// INFO informational message.
	INFO LogLevel = iota
	// WARN warning message
	WARN LogLevel = iota
	// ERROR error message
	ERROR LogLevel = iota
	// MAXLEVEL max log level
	MAXLEVEL LogLevel = iota - 1
)

func (LogLevel) String

func (i LogLevel) String() string

type Logger

type Logger interface {
	// Print calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Print.
	Print(v ...interface{})
	// Printf calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Printf.
	Printf(format string, v ...interface{})
	// Println calls l.Output to print to the logger. Arguments are handled in the manner of fmt.Println.
	Println(v ...interface{})

	// Fatal write message(level=FATAL) to the logger followed by a call to os.Exit(1).
	// Arguments are handled in the manner of fmt.Print.
	Fatal(v ...interface{})
	// Fatalf write message(level=FATAL) to the logger followed by a call to os.Exit(1).
	// Arguments are handled in the manner of fmt.Printf.
	Fatalf(format string, v ...interface{})
	// Fatalln iwrite message(level=FATAL) to the logger followed by a call to os.Exit(1).
	// Arguments are handled in the manner of fmt.Println.
	Fatalln(v ...interface{})

	// Panic write message(level=PANIC) to the logger followed by a call to panic().
	// Arguments are handled in the manner of fmt.Print.
	Panic(v ...interface{})
	// Panicf write message(level=PANIC) to the logger followed by a call to panic().
	// Arguments are handled in the manner of fmt.Printf.
	Panicf(format string, v ...interface{})
	// Panicln write message(level=PANIC) to the logger followed by a call to panic().
	// Arguments are handled in the manner of fmt.Println.
	Panicln(v ...interface{})
}

Logger minimum logging interface

type LoggerModifier added in v0.0.5

type LoggerModifier interface {
	// SetFlags sets the output flags for the logger.
	SetFlags(flag int)

	// Flags returns the output flags for the logger.
	Flags() int

	// SetPrefix sets the output prefix for the logger.
	SetPrefix(prefix string)

	// Prefix returns the output prefix for the logger.
	Prefix() string

	// SetOutput sets the output destination for the logger.
	SetOutput(w io.Writer)
}

LoggerModifier leveld logging modifier interface

Directories

Path Synopsis
Package gologif is wrapper of a standard "log" package.
Package gologif is wrapper of a standard "log" package.

Jump to

Keyboard shortcuts

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