slog

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2022 License: MulanPSL-2.0 Imports: 6 Imported by: 0

README

slog

介绍

{以下是 Gitee 平台说明,您可以替换此简介 Gitee 是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 无论是个人、团队、或是企业,都能够用 Gitee 实现代码托管、项目管理、协作开发。企业项目请看 https://gitee.com/enterprises}

软件架构

软件架构说明

安装教程
  1. xxxx
  2. xxxx
  3. xxxx
使用说明
  1. xxxx
  2. xxxx
  3. xxxx
参与贡献
  1. Fork 本仓库
  2. 新建 Feat_xxx 分支
  3. 提交代码
  4. 新建 Pull Request
特技
  1. 使用 Readme_XXX.md 来支持不同的语言,例如 Readme_en.md, Readme_zh.md
  2. Gitee 官方博客 blog.gitee.com
  3. 你可以 https://gitee.com/explore 这个地址来了解 Gitee 上的优秀开源项目
  4. GVP 全称是 Gitee 最有价值开源项目,是综合评定出的优秀开源项目
  5. Gitee 官方提供的使用手册 https://gitee.com/help
  6. Gitee 封面人物是一档用来展示 Gitee 会员风采的栏目 https://gitee.com/gitee-stars/

Documentation

Index

Constants

View Source
const (
	// Console 输出至控制台
	Console printOut = iota
	// File 输出至日志文件
	File
)
View Source
const DefWriteMaxWaitTime time.Duration = 2 * time.Second

DefWriteMaxWaitTime 默认的日志写入最大等待时长 当存在连续不断的日志进入缓存队列时 向文件写入记录并不执行关闭操作 若无写入行为时间超过该时间,执行文件关闭

Variables

View Source
var DefLogLevel = INFO

DefLogLevel 默认的日志级别

View Source
var DefPrint printOut = Console

DefPrint 输出方向 设置一个全局的输出方向, 但函数Printf 不受此参数控制,Printf()始终将日志输出到控制台

View Source
var Prefix = ""

Prefix 日志前缀--可携带路径参数,如: “log/slog” 日志将会输出到 项目根目录/log/slog20220801.log

Functions

func All

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

func Debug

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

func Error

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

func Fatal

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

func FileNameSuffix

func FileNameSuffix(unix ...int64) string

func Info

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

func Off

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

func Printf

func Printf(lv LogLevel, format string, v ...interface{})

Printf 向控制台输出日志 lv 日志登录

func RunPath

func RunPath(skip int) (filepath, line, funcName string)

RunPath 获取运行函数所在文件路径、行号、函数名 runtime.Caller(2) 获取前2层调用者信息

func TimeNanoToString

func TimeNanoToString(unix ...int64) string

TimeNanoToString 获取当前时间转为人类可读模式--纳秒

func TimeToString

func TimeToString(unix ...int64) string

TimeToString 获取当天日期

func Warn

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

func WriteSlog

func WriteSlog(lv LogLevel, body string)

Types

type LogLevel

type LogLevel int

LogLevel 日志级别

const (
	ALL LogLevel = iota
	DEBUG
	INFO
	WARN
	ERROR
	FATAL
	OFF
)

type WriteModel

type WriteModel int

WriteModel 日志写入模式 当前提供结构化与单行写入

const (
	// WriteSingleLine 单行模式 所有信息都保存到一行
	WriteSingleLine WriteModel = iota
	// WriteStructured 结构化模式
	WriteStructured
)
var DefWriteModel WriteModel = WriteStructured

DefWriteModel 默认的日志写入模式

Jump to

Keyboard shortcuts

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