logs

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: GPL-2.0 Imports: 8 Imported by: 0

README

基于 zap 日志库封装的日志组件

此日志库会在项目根目录下创建 log目录,用于存放日志文件,且日志文件按照天进行切割

(1)直接使用

package main

import "gitee.com/xintujing/gopkg/logs"

func main() {
	logs.Info("test...")
}

(2)自定义 logs 配置

package main

import "gitee.com/xintujing/gopkg/logs"

func main() {
	// 自定义 config信息
	logs.InitWithConfig(logs.NewConfig(
		logs.WithServiceName("my_service"),
		logs.WithPath("my_logs/"),
	))
	logs.Info("test...")
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Debug

func Debug(args ...interface{})

func Debugf

func Debugf(template string, args ...interface{})

func Error

func Error(args ...interface{})

func Errorf

func Errorf(template string, args ...interface{})

func Info

func Info(args ...interface{})

func Infof

func Infof(template string, args ...interface{})

func InitWithConfig

func InitWithConfig(cfg *config)

InitWithConfig 传入自定义日志的配置选项

func NewConfig

func NewConfig(opts ...ConfigOption) *config

func Panic

func Panic(args ...interface{})

func Panicf

func Panicf(template string, args ...interface{})

func Warn

func Warn(args ...interface{})

func Warnf

func Warnf(template string, args ...interface{})

Types

type ConfigOption

type ConfigOption interface {
	// contains filtered or unexported methods
}

func WithLevel

func WithLevel(level string) ConfigOption

func WithMaxAge

func WithMaxAge(max int) ConfigOption

func WithMaxsize

func WithMaxsize(max int) ConfigOption

func WithPath

func WithPath(path string) ConfigOption

func WithServiceName

func WithServiceName(serviceName string) ConfigOption

Jump to

Keyboard shortcuts

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