gorogger

package module
v0.0.0-...-b630195 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2023 License: MIT Imports: 7 Imported by: 0

README

gorogger

zap logger を利用してコンソールおよびファイルへログ出力する。
それぞれに、以下設定可能。

  • ログレベル選択
    dbg,info,warn,err, ""
  • Output の Enable/Disable 選択
    ログレベル選択において""選択

How to run

logger_test.go

Setup

config.toml

   // config.toml
   // LEVEL = dbg,info,warn,err, ""
   [logger]
   CONSOLE_LEVEL = "dbg"
   LOG_LEVEL = "err"
   LOG_PATH = "./testData/test_log.json"

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	// contains filtered or unexported fields
}

func NewLogger

func NewLogger(
	logPath string,
	logLevel OutputLevel,
	consoleLevel OutputLevel,
) *Logger

func (*Logger) Close

func (l *Logger) Close()

func (*Logger) Debug

func (l *Logger) Debug(message string, val interface{}, keys ...string)

Debug : use zap logger. If val don't exist, set "nil".

func (*Logger) Error

func (l *Logger) Error(message string, val interface{}, keys ...string)

Error : use zap logger. If val don't exist, set "nil".

func (*Logger) Info

func (l *Logger) Info(message string, val interface{}, keys ...string)

Info : use zap logger. If val don't exist, set "nil".

func (*Logger) Warn

func (l *Logger) Warn(message string, val interface{}, keys ...string)

Warn : use zap logger. If val don't exist, set "nil".

type OutputLevel

type OutputLevel string
const (
	NOT_USED OutputLevel = "" // Don't output
	DBG      OutputLevel = "debug"
	INFO     OutputLevel = "info"
	WARN     OutputLevel = "warn"
	ERR      OutputLevel = "error"
)

func GetLevel

func GetLevel(lvl string) OutputLevel

Jump to

Keyboard shortcuts

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