# README
log SDK
找到日志模块
为了更好地提供日志功能。
为了区分环境,我们引入加入DEV(开发环境) UAT(测试环境) PRO(开发环境)
。
使用方式
1 日志环境变量,具体见env模块
1 对于不同的服务器环境,日志会选择不同的handle:
例如:
对于开发环境,会把日志打印到控制台
对于线上,测试环境,日志会打印到远程日志中心。
export UDP_LOG_ADDR=118.178.140.41
export UDP_LOG_PORT=1223
export SYSLOG_ADDR=118.178.140.41
export SYSLOG_PORT=1224
名称 | 说明 |
---|---|
UDP_LOG_ADDR | UDP远程日志中心IP地址 |
UDP_LOG_PORT | UDP远程日志中心port |
SYSLOG_ADDR | syslog远程日志中心IP地址 |
SYSLOG_PORT | syslog远程日志中心port |
配置
具体见Config结构体,通过Init函数实现初始化
example
import (
"github.com/zdao-pro/sky_blue/pkg/log"
)
// main.go
func main() {
log.Init(nil)
log.Info("%s", "222322")
}
# Functions
Access ...
Accessc ...
Debug ...
Debugc ...
Debugv logs a message at the debug log level.
Error ...
Errorc ...
Errorv logs a message at the error log level.
Fatalv logs a message at the error log level.
Fetal ...
Fetalc ...
Info ...
Infoc ...
Infov logs a message at the info log level.
Init ...
KV return a log kv for logging field.
KVDuration construct Field with Duration value.
KVFloat32 construct Field with float32 value.
KVFloat64 construct Field with float64 value.
KVInt construct D with int value.
KVInt64 construct D with int64 value.
KVString ...
KVUint construct Field with uint value.
KVUint64 construct Field with uint64 value.
Warn ...
Warnc ...
Warnv logs a message at the warning log level.
# Constants
DType enum.
DType enum.
DType enum.
DType enum.
DType enum.
DType enum.
DType enum.
DType enum.
DType enum.