{"modulePath":"github.com/RedAFD/code-core","version":"v1.8.3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package log\n\n## Constants\n\n```go\nconst (\n\tTRACE = iota\n\tDEBUG\n\tINFO\n\tWARN\n\tERROR\n\tCRITICAL\n\tFATAL\n)\n```\nlog levels\n\n## Functions\n\n```go\nfunc Close()\n```\nClose closes all the loggers\n\n```go\nfunc Critical(skip int, format string, v ...interface{})\n```\nCritical records critical log\n\n```go\nfunc Debug(format string, v ...interface{})\n```\nDebug records debug log\n\n```go\nfunc DelLogger(mode string) error\n```\nDelLogger removes loggers that are for the given mode\n\n```go\nfunc DiscardXORMLogger()\n```\nDiscardXORMLogger inits a blank logger for xorm\n\n```go\nfunc Error(skip int, format string, v ...interface{})\n```\nError records error log\n\n```go\nfunc Fatal(skip int, format string, v ...interface{})\n```\nFatal records error log and exit process\n\n```go\nfunc Info(format string, v ...interface{})\n```\nInfo records info log\n\n```go\nfunc NewGitLogger(logPath string)\n```\nNewGitLogger create a logger for git FIXME: use same log level as other loggers.\n\n```go\nfunc NewLogger(bufLen int64, mode, config string)\n```\nNewLogger create a logger\n\n```go\nfunc NewXORMLogger(bufferlen int64, mode, config string)\n```\nNewXORMLogger generate logger for xorm FIXME: configable\n\n```go\nfunc Register(name string, log loggerType)\n```\nRegister registers given logger provider to adapters.\n\n```go\nfunc Trace(format string, v ...interface{})\n```\nTrace records trace log\n\n```go\nfunc Warn(format string, v ...interface{})\n```\nWarn records warning log\n\n## Types\n\n```go\ntype Brush func(string) string\n```\nBrush brush type\n\n```go\nfunc NewBrush(color string) Brush\n```\nNewBrush create a brush according color\n\n```go\ntype ConnWriter struct {\n\tReconnectOnMsg bool   `json:\"reconnectOnMsg\"`\n\tReconnect      bool   `json:\"reconnect\"`\n\tNet            string `json:\"net\"`\n\tAddr           string `json:\"addr\"`\n\tLevel          int    `json:\"level\"`\n\t// contains filtered or unexported fields\n}\n```\nConnWriter implements LoggerInterface. it writes messages in keep-live tcp connection.\n\n```go\nfunc (cw *ConnWriter) Destroy()\n```\nDestroy destroy connection writer and close tcp listener.\n\n```go\nfunc (cw *ConnWriter) Flush()\n```\nFlush no things for this implementation\n\n```go\nfunc (cw *ConnWriter) Init(jsonconfig string) error\n```\nInit inits connection writer with json config. json config only need key \"level\".\n\n```go\nfunc (cw *ConnWriter) WriteMsg(msg string, skip, level int) error\n```\nWriteMsg writes message in connection. if connection is down, try to re-connect.\n\n```go\ntype ConsoleWriter struct {\n\tLevel int `json:\"level\"`\n\t// contains filtered or unexported fields\n}\n```\nConsoleWriter implements LoggerInterface and writes messages to terminal.\n\n```go\nfunc (cw *ConsoleWriter) Destroy()\n```\nDestroy when writer is destroy\n\n```go\nfunc (cw *ConsoleWriter) Flush()\n```\nFlush when log should be flushed\n\n```go\nfunc (cw *ConsoleWriter) Init(config string) error\n```\nInit inits connection writer with json config. json config only need key \"level\".\n\n```go\nfunc (cw *ConsoleWriter) WriteMsg(msg string, skip, level int) error\n```\nWriteMsg writes message in console. if OS is windows, ignore colors.\n\n```go\ntype FileLogWriter struct {\n\t*log.Logger\n\n\t// The opened file\n\tFilename string `json:\"filename\"`\n\n\t// Rotate at size\n\tMaxsize int `json:\"maxsize\"`\n\n\t// Rotate daily\n\tDaily   bool  `json:\"daily\"`\n\tMaxdays int64 `json:\"maxdays\"`\n\n\tRotate bool `json:\"rotate\"`\n\n\tLevel int `json:\"level\"`\n\t// contains filtered or unexported fields\n}\n```\nFileLogWriter implements LoggerInterface. It writes messages by lines limit, file size limit, or time frequency.\n\n```go\nfunc (w *FileLogWriter) Destroy()\n```\nDestroy destroy file logger, close file writer.\n\n```go\nfunc (w *FileLogWriter) DoRotate() error\n```\nDoRotate means it need to write file in new file. new file name like xx.log.2013-01-01.2\n\n```go\nfunc (w *FileLogWriter) Flush()\n```\nFlush flush file logger. there are no buffering messages in file logger in memory. flush file means sync file from disk.\n\n```go\nfunc (w *FileLogWriter) Init(config string) error\n```\nInit file logger with json config. config like:\n\n\t{\n\t\"filename\":\"log/gogs.log\",\n\t\"maxsize\":1\u003c\u003c30,\n\t\"daily\":true,\n\t\"maxdays\":15,\n\t\"rotate\":true\n\t}\n\n```go\nfunc (w *FileLogWriter) StartLogger() error\n```\nStartLogger start file logger. create log file and set to locker-inside file writer.\n\n```go\nfunc (w *FileLogWriter) WriteMsg(msg string, skip, level int) error\n```\nWriteMsg writes logger message into file.\n\n```go\ntype Logger struct {\n\t// contains filtered or unexported fields\n}\n```\nLogger is default logger in beego application. it can contain several providers and log message into all providers.\n\n```go\nvar (\n\n\t// GitLogger logger for git\n\tGitLogger *Logger\n)\n```\n\n```go\nfunc (l *Logger) Close()\n```\nClose closes logger, flush all chan data and destroy all adapter instances.\n\n```go\nfunc (l *Logger) Critical(skip int, format string, v ...interface{})\n```\nCritical records critical log\n\n```go\nfunc (l *Logger) Debug(format string, v ...interface{})\n```\nDebug records debug log\n\n```go\nfunc (l *Logger) DelLogger(adapter string) error\n```\nDelLogger removes a logger adapter instance.\n\n```go\nfunc (l *Logger) Error(skip int, format string, v ...interface{})\n```\nError records error log\n\n```go\nfunc (l *Logger) Fatal(skip int, format string, v ...interface{})\n```\nFatal records error log and exit the process\n\n```go\nfunc (l *Logger) Flush()\n```\nFlush flushes all chan data.\n\n```go\nfunc (l *Logger) Info(format string, v ...interface{})\n```\nInfo records information log\n\n```go\nfunc (l *Logger) SetLogger(adapter string, config string) error\n```\nSetLogger sets new logger instance with given logger adapter and config.\n\n```go\nfunc (l *Logger) StartLogger()\n```\nStartLogger starts logger chan reading.\n\n```go\nfunc (l *Logger) Trace(format string, v ...interface{})\n```\nTrace records trace log\n\n```go\nfunc (l *Logger) Warn(format string, v ...interface{})\n```\nWarn records warning log\n\n```go\ntype LoggerAsWriter struct {\n\t// contains filtered or unexported fields\n}\n```\nLoggerAsWriter is a io.Writer shim around the gitea log\n\n```go\nfunc NewLoggerAsWriter(level string) *LoggerAsWriter\n```\nNewLoggerAsWriter creates a Writer representation of the logger with setable log level\n\n```go\nfunc (l *LoggerAsWriter) Log(msg string)\n```\nLog takes a given string and logs it at the set log-level\n\n```go\nfunc (l *LoggerAsWriter) Write(p []byte) (int, error)\n```\nWrite implements the io.Writer interface to allow spoofing of macaron\n\n```go\ntype LoggerInterface interface {\n\tInit(config string) error\n\tWriteMsg(msg string, skip, level int) error\n\tDestroy()\n\tFlush()\n}\n```\nLoggerInterface represents behaviors of a logger provider.\n\n```go\nfunc NewConn() LoggerInterface\n```\nNewConn creates new ConnWrite returning as LoggerInterface.\n\n```go\nfunc NewConsole() LoggerInterface\n```\nNewConsole create ConsoleWriter returning as LoggerInterface.\n\n```go\nfunc NewFileWriter() LoggerInterface\n```\nNewFileWriter create a FileLogWriter returning as LoggerInterface.\n\n```go\nfunc NewSMTPWriter() LoggerInterface\n```\nNewSMTPWriter creates smtp writer.\n\n```go\ntype MuxWriter struct {\n\tsync.Mutex\n\t// contains filtered or unexported fields\n}\n```\nMuxWriter an \\*os.File writer with locker.\n\n```go\nfunc (l *MuxWriter) SetFd(fd *os.File)\n```\nSetFd sets os.File in writer.\n\n```go\nfunc (l *MuxWriter) Write(b []byte) (int, error)\n```\nWrite writes to os.File.\n\n```go\ntype SMTPWriter struct {\n\tUsername           string   `json:\"Username\"`\n\tPassword           string   `json:\"password\"`\n\tHost               string   `json:\"Host\"`\n\tSubject            string   `json:\"subject\"`\n\tRecipientAddresses []string `json:\"sendTos\"`\n\tLevel              int      `json:\"level\"`\n}\n```\nSMTPWriter implements LoggerInterface and is used to send emails via given SMTP-server.\n\n```go\nfunc (sw *SMTPWriter) Destroy()\n```\nDestroy when writer is destroy\n\n```go\nfunc (sw *SMTPWriter) Flush()\n```\nFlush when log should be flushed\n\n```go\nfunc (sw *SMTPWriter) Init(jsonconfig string) error\n```\nInit smtp writer with json config. config like:\n\n\t{\n\t\t\"Username\":\"example@gmail.com\",\n\t\t\"password:\"password\",\n\t\t\"host\":\"smtp.gmail.com:465\",\n\t\t\"subject\":\"email title\",\n\t\t\"sendTos\":[\"email1\",\"email2\"],\n\t\t\"level\":LevelError\n\t}\n\n```go\nfunc (sw *SMTPWriter) WriteMsg(msg string, skip, level int) error\n```\nWriteMsg writes message in smtp writer. it will send an email with subject and only this message.\n\n```go\ntype XORMLogBridge struct {\n\t// contains filtered or unexported fields\n}\n```\nXORMLogBridge a logger bridge from Logger to xorm\n\n```go\nvar (\n\t// XORMLogger the logger for xorm\n\tXORMLogger *XORMLogBridge\n)\n```\n\n```go\nfunc (l *XORMLogBridge) Debug(v ...interface{})\n```\nDebug show debug log\n\n```go\nfunc (l *XORMLogBridge) Debugf(format string, v ...interface{})\n```\nDebugf show debug log\n\n```go\nfunc (l *XORMLogBridge) Error(v ...interface{})\n```\nError show error log\n\n```go\nfunc (l *XORMLogBridge) Errorf(format string, v ...interface{})\n```\nErrorf show error log\n\n```go\nfunc (l *XORMLogBridge) Info(v ...interface{})\n```\nInfo show information level log\n\n```go\nfunc (l *XORMLogBridge) Infof(format string, v ...interface{})\n```\nInfof show information level log\n\n```go\nfunc (l *XORMLogBridge) IsShowSQL() bool\n```\nIsShowSQL if record SQL\n\n```go\nfunc (l *XORMLogBridge) Level() core.LogLevel\n```\nLevel get logger level\n\n```go\nfunc (l *XORMLogBridge) SetLevel(level core.LogLevel)\n```\nSetLevel set logger level\n\n```go\nfunc (l *XORMLogBridge) ShowSQL(show ...bool)\n```\nShowSQL set if record SQL\n\n```go\nfunc (l *XORMLogBridge) Warn(v ...interface{})\n```\nWarn show warning log\n\n```go\nfunc (l *XORMLogBridge) Warnf(format string, v ...interface{})\n```\nWarnf show warnning log\n\n","path":"github.com/RedAFD/code-core/modules/log","name":"log","synopsis":"","isRedistributable":true}
