Documentation ¶
Index ¶
- Constants
- Variables
- func Close()
- func Debug(out, format string, a ...interface{})
- func Dial(addr string) (*smtp.Client, error)
- func Error(out, format string, a ...interface{})
- func Fatal(out, format string, a ...interface{})
- func GetLevel(levelStr string) (level logLevel, err error)
- func GetLevelStr(level logLevel) (levelStr string)
- func Info(out, format string, a ...interface{})
- func InitLog()
- func SendMailUsingTLS(addr string, auth smtp.Auth, from string, to []string, msg []byte) (err error)
- func Trace(out, format string, a ...interface{})
- func Warning(out, format string, a ...interface{})
- type EmailLog
- func (e *EmailLog) Close()
- func (e *EmailLog) Debug(format string, a ...interface{})
- func (e *EmailLog) Error(format string, a ...interface{})
- func (e *EmailLog) Fatal(format string, a ...interface{})
- func (e *EmailLog) Info(format string, a ...interface{})
- func (e *EmailLog) SendEmailLog(subject, body string)
- func (e *EmailLog) Trace(format string, a ...interface{})
- func (e *EmailLog) Unknown(format string, a ...interface{})
- func (e *EmailLog) Warning(format string, a ...interface{})
- type FileLog
- func (f *FileLog) Close()
- func (f *FileLog) Debug(format string, a ...interface{})
- func (f *FileLog) Error(format string, a ...interface{})
- func (f *FileLog) Fatal(format string, a ...interface{})
- func (f *FileLog) Info(format string, a ...interface{})
- func (f *FileLog) Trace(format string, a ...interface{})
- func (f *FileLog) Unknown(format string, a ...interface{})
- func (f *FileLog) Warning(format string, a ...interface{})
- type StdoutLog
- func (c *StdoutLog) Close()
- func (c *StdoutLog) Debug(format string, a ...interface{})
- func (c *StdoutLog) Error(format string, a ...interface{})
- func (c *StdoutLog) Fatal(format string, a ...interface{})
- func (c *StdoutLog) Info(format string, a ...interface{})
- func (c *StdoutLog) Trace(format string, a ...interface{})
- func (c *StdoutLog) Unknown(format string, a ...interface{})
- func (c *StdoutLog) Warning(format string, a ...interface{})
Constants ¶
View Source
const ( UNKNOWN logLevel = iota DEBUG TRACE INFO WARNING ERROR FATAL )
从上往下,日志级别越高
Variables ¶
View Source
var ( Flog *FileLog //文件日志对象 Slog *StdoutLog //标准输出对象 Elog *EmailLog //email对象 )
Functions ¶
Types ¶
type EmailLog ¶
type EmailLog struct { Enable bool `conf:"enable"` //配置文件中,是否启用 Level logLevel `conf:"run_level"` //配置文件中,email日志等级. Host string `conf:"host"` // 邮箱服务器地址,如smtp.163.com Port int `conf:"port"` //邮箱服务器端口,如25,465 SendEmail string `conf:"send_email"` //发件人邮箱地址 SendPasswd string `conf:"send_passwd"` //发件人邮箱密码(明文形式) Recipient string `conf:"recipient"` // 接收者.如有多个,则以英文逗号(,)隔开 EmailCC string `conf:"emailCC"` // 抄送者.如有多个,则以英文逗号(,)隔开 MaxEmailChan int `conf:"max_email_chan"` //异步发送邮件,最大缓存邮件数 Mail *gomail.Message //发邮件对象 EmailChan chan *emailMsg //邮件日志存放管道 }
func NewEmailLog ¶
func (*EmailLog) SendEmailLog ¶
SendEmail body支持html格式字符串
type FileLog ¶
type FileLog struct { Enable bool `conf:"enable"` //配置文件中,是否启用 Level logLevel `conf:"run_level"` //配置文件中,file日志等级. FilePath string `conf:"file_path"` //配置文件中,文件路径. FileName string `conf:"file_name"` //配置文件中,文件名. MaxFileSize int64 `conf:"max_file_size"` //配置文件中,日志文件最大大小. MaxLogChan int `conf:"max_log_chan"` //配置文件中,日志存放管道最大数 FileObj *os.File //标准日志文件对象. ErrFileObj *os.File //单独错误日志文件对象. LogChan chan *logMsg //日志存放管道 }
输出到文件.
func NewFileLog ¶
type StdoutLog ¶
type StdoutLog struct { Enable bool `conf:"enable"` //配置文件中,是否启用 Level logLevel `conf:"run_level"` //配置文件中,标准输出日志等级. }
输出到标准控制台.
func NewStdoutLog ¶
Click to show internal directories.
Click to hide internal directories.