log

package
v1.4.5 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2024 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Overview

Example
package main

import (
	"github.com/helloh2o/lucky/log"
	l "log"
)

func main() {
	name := "Leaf"

	log.Debug("My name is %v", name)
	log.Release("My name is %v", name)
	log.Error("My name is %v", name)
	// log.Fatal("My name is %v", name)

	logger, err := log.New("release", "", l.LstdFlags)
	if err != nil {
		return
	}
	defer logger.Close()

	logger.Debug("will not print")
	logger.Release("My name is %v", name)

	log.Export(logger)

	log.Debug("will not print")
	log.Release("My name is %v", name)
}
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Close

func Close()

Close default logger

func Debug

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

Debug print

func Error

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

Error print

func Export

func Export(logger *Logger)

Export It's dangerous to call the method on logging

func Fatal

func Fatal(format string, a ...interface{})

Fatal print

func Release

func Release(format string, a ...interface{})

Release print

func SetLogLevelDefault added in v1.2.7

func SetLogLevelDefault(lv string)

func Warn added in v1.3.5

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

Warn print

Types

type Logger

type Logger struct {
	BaseFile *os.File
	// contains filtered or unexported fields
}

Logger warp

func New

func New(strLevel string, pathname string, flag int) (*Logger, error)

New a logger

func (*Logger) Close

func (logger *Logger) Close()

Close It's dangerous to call the method on logging

func (*Logger) Debug

func (logger *Logger) Debug(format string, a ...interface{})

Debug log

func (*Logger) Error

func (logger *Logger) Error(format string, a ...interface{})

Error log

func (*Logger) Fatal

func (logger *Logger) Fatal(format string, a ...interface{})

Fatal panic

func (*Logger) GetOutputLv added in v1.2.7

func (logger *Logger) GetOutputLv() int

read log lv

func (*Logger) Release

func (logger *Logger) Release(format string, a ...interface{})

Release log

func (*Logger) SetLogLevel added in v1.2.7

func (logger *Logger) SetLogLevel(strLevel string)

update log level

func (*Logger) Warn added in v1.3.5

func (logger *Logger) Warn(format string, a ...interface{})

Warn log

Jump to

Keyboard shortcuts

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