Documentation
¶
Overview ¶
* @Author: nijineko * @Date: 2025-06-08 11:03:48 * @LastEditTime: 2025-06-08 17:05:59 * @LastEditors: nijineko * @Description: log file handle utility package * @FilePath: \noa\file.go
* @Author: nijineko * @Date: 2025-06-08 10:52:00 * @LastEditTime: 2025-06-08 13:14:48 * @LastEditors: nijineko * @Description: log handle package * @FilePath: \noa\handle.go
* @Author: nijineko * @Date: 2025-06-08 10:29:01 * @LastEditTime: 2025-06-15 10:56:23 * @LastEditors: nijineko * @Description: noa log package * @FilePath: \noa\log.go
* @Author: nijineko * @Date: 2025-06-08 10:59:01 * @LastEditTime: 2025-06-15 10:49:36 * @LastEditors: nijineko * @Description: log output package * @FilePath: \noa\output.go
* @Author: nijineko * @Date: 2025-06-10 21:24:26 * @LastEditTime: 2025-06-10 22:29:29 * @LastEditors: nijineko * @Description: text log encoder * @FilePath: \noa\textEncoder.go
Index ¶
- Constants
- type AfterHandleFunc
- type BeforeHandleFunc
- type LogConfig
- func (l *LogConfig) AddAfterHandle(HandleFunc AfterHandleFunc)
- func (l *LogConfig) AddBeforeHandle(HandleFunc BeforeHandleFunc)
- func (l *LogConfig) Debug(Source string, Data ...any)
- func (l *LogConfig) Error(Source string, Data ...any)
- func (l *LogConfig) Fatal(Source string, Data ...any)
- func (l *LogConfig) Info(Source string, Data ...any)
- func (l *LogConfig) Print(Level int, Source string, Data ...any)
- func (l *LogConfig) SetEncoder(Encoder encoder.Encoder)
- func (l *LogConfig) Warning(Source string, Data ...any)
- type LogConfigEncoder
- type LogConfigErrors
- type LogConfigWriter
- type TextEncoder
- type TextEncoderConfigNewline
Constants ¶
const ( DEBUG = iota + 0 INFO WARNING ERROR FATAL OFF )
default log levels
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LogConfig ¶
type LogConfig struct {
Level int // log level
RemoveColor bool // remove color from log output
TimeFormat string // log prefix time format
Errors LogConfigErrors // error configuration for logging
Writer LogConfigWriter // writer configuration for logging to files
Encoder LogConfigEncoder // log encoder
// contains filtered or unexported fields
}
Log config structure
func NewLog ¶
func NewLog() *LogConfig
*
- @description: Create a new log configuration instance
- @return {*LogConfig} a log configuration instance
func (*LogConfig) AddAfterHandle ¶
func (l *LogConfig) AddAfterHandle(HandleFunc AfterHandleFunc)
*
- @description: Add a handle function to run after logging
- @description: if error returned, will panic
- @param {AfterHandleFunc} HandleFunc
func (*LogConfig) AddBeforeHandle ¶
func (l *LogConfig) AddBeforeHandle(HandleFunc BeforeHandleFunc)
*
- @description: Add a handle function to run before logging
- @description: if error returned, will panic
- @param {BeforeHandleFunc} HandleFun
func (*LogConfig) Debug ¶
*
- @description: print debug log
- @param {string} Source Log source (e.g., file name, function name)
- @param {...any} Data print data
func (*LogConfig) Error ¶
*
- @description: print error log
- @param {string} Source Log source (e.g., file name, function name)
- @param {...any} Data print data
func (*LogConfig) Fatal ¶
*
- @description: print fatal log
- @param {string} Source Log source (e.g., file name, function name)
- @param {...any} Data print data
func (*LogConfig) Info ¶
*
- @description: print info log
- @param {string} Source Log source (e.g., file name, function name)
- @param {...any} Data print data
func (*LogConfig) Print ¶
*
- @description: Print log
- @param {int} Level Log level
- @param {string} Source Log source (e.g., file name, function name)
- @param {...any} Data print data
func (*LogConfig) SetEncoder ¶
*
- @description: Set encoder for the log instance
- @param {encoder.Encoder} Encoder encoder instance
type LogConfigEncoder ¶
Log config encoder structure
type LogConfigErrors ¶
type LogConfigErrors struct {
StackTrace bool // whether to print stack trace for errors
CallerSkip int // skip number of stack frames to find the caller
}
Log config error structure
type LogConfigWriter ¶
type LogConfigWriter struct {
Enable bool // enable log file writing
FolderPath string // folder path for log files
TimeFormat string // time format for log file names
// contains filtered or unexported fields
}
Log config writer structure
type TextEncoder ¶
type TextEncoder struct {
Newline TextEncoderConfigNewline // newline configuration
Log *LogConfig // noa log instance
}
TextEncoder struct
func NewTextEncoder ¶
func NewTextEncoder(Log *LogConfig) *TextEncoder
*
- @description: Create a new TextEncoder instance
- @return {*TextEncoder} TextEncoder instance
func (*TextEncoder) WriteFileExtension ¶
func (te *TextEncoder) WriteFileExtension() string
return file extension for the encoded file
Directories
¶
| Path | Synopsis |
|---|---|
|
* @Author: nijineko * @Date: 2025-06-10 21:56:37 * @LastEditTime: 2025-06-10 21:56:43 * @LastEditors: nijineko * @Description: noa encoder context package * @FilePath: \noa\encoder\context.go
|
* @Author: nijineko * @Date: 2025-06-10 21:56:37 * @LastEditTime: 2025-06-10 21:56:43 * @LastEditors: nijineko * @Description: noa encoder context package * @FilePath: \noa\encoder\context.go |
|
* @Author: nijineko * @Date: 2025-06-08 12:42:57 * @LastEditTime: 2025-06-12 11:10:17 * @LastEditors: nijineko * @Description: noa errors package * @FilePath: \noa\errors\errors.go
|
* @Author: nijineko * @Date: 2025-06-08 12:42:57 * @LastEditTime: 2025-06-12 11:10:17 * @LastEditors: nijineko * @Description: noa errors package * @FilePath: \noa\errors\errors.go |
|
* @Author: nijineko * @Date: 2025-06-10 12:12:04 * @LastEditTime: 2025-06-10 12:12:05 * @LastEditors: nijineko * @Description: pad space util * @FilePath: \noa\tools\padSpace.go
|
* @Author: nijineko * @Date: 2025-06-10 12:12:04 * @LastEditTime: 2025-06-10 12:12:05 * @LastEditors: nijineko * @Description: pad space util * @FilePath: \noa\tools\padSpace.go |