log

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: MIT Imports: 7 Imported by: 45

README

log

golang logger based log

Doc

ref to: https://godoc.org/github.com/yeqown/log

Usage

sample-1.go

import (
  "github.com/yeqown/log"
)

func main() {
  intptr := new(int)
  *intprt = 9999

  struct_var := struct {
    Name string
    Age  int
  }{"Tonn", 24}

  // to set file output for default logger
  SetFileOutput("/path/to/logfile", "default")

  // also support Debug, Warn, Fatal, Error
  log.Info("this is a struct var: ", struct_var)
  log.Info("this is a int ptr and var: ", a, *a)
  log.Infof("%d is not equal to %d", 1, 2)
}

sample-2.go

import (
  "github.com/yeqown/log"
)

func main() {
  // to make self logger
  l := log.NewLogger()

  intptr := new(int)
  *intprt = 9999

  struct_var := struct {
    Name string
    Age  int
  }{"Tonn", 24}

  // to set file output for default logger
  l.SetFileOutput("/path/to/logfile", "app")

  // also support Debug, Warn, Fatal, Error
  l.Info("this is a struct var: ", struct_var)
  l.Info("this is a int ptr and var: ", a, *a)
  l.Infof("%d is not equal to %d", 1, 2)
}

Using preview

Note: this screenshot is log_test.go output's screenshot.

screenshot

Documentation

Overview

Package log .

this log is based `https://github.com/silenceper/log` but more functions:

1. can be set to output to file

2. log file can splited into files day by day, just like `app.20060102.log`

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

Debug .

func Debugf

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

Debugf .

func Error

func Error(args ...interface{})

Error .

func Errorf

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

Errorf .

func Fatal

func Fatal(args ...interface{})

Fatal .

func Fatalf

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

Fatalf .

func Info

func Info(args ...interface{})

Info .

func Infof

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

Infof .

func NewLogger

func NewLogger() *logger

NewLogger 实例化,供自定义

func SetFileOutput

func SetFileOutput(logPath, filename string)

SetFileOutput .

func SetLogLevel

func SetLogLevel(level Level)

SetLogLevel .

func Warn

func Warn(args ...interface{})

Warn .

func Warnf

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

Warnf .

Types

type Level

type Level int

Level of log

const (

	// LevelFatal .
	LevelFatal Level = iota
	// LevelError .
	LevelError
	// LevelWarning .
	LevelWarning
	// LevelInfo .
	LevelInfo
	// LevelDebug .
	LevelDebug
)

Jump to

Keyboard shortcuts

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