log4go | Logging package similar to log4j for the Go programming
kandi X-RAY | log4go Summary
kandi X-RAY | log4go Summary
Please see for more log4go usages. My personal package (github.com/AlexStocks/goext/log) wrappered log4go functions further more which provides the most powerful log4go.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Create a new FileLogWriter
- Format log record
- confToFileLogWriter creates a new FileLogWriter
- confToXMLLogWriter creates a FileLogWriter
- Create a socket log writer
- loadConfFile loads the configuration from a file
- Test if json is valid
- Easyjson15d5decodeg encodes a LogRecord into out .
- Convert to socket log writer
- Easyjson15d5d517DecodegDecodeg decodes into out .
log4go Key Features
log4go Examples and Code Snippets
Community Discussions
Trending Discussions on log4go
QUESTION
func (log Logger) Warn(arg0 interface{}, args ...interface{}) error {
const (
lvl = WARNING
)
var msg string
switch first := arg0.(type) {
case string:
// Use the string as a format string
msg = fmt.Sprintf(first, args...)
case func() string:
// Log the closure (no other arguments used)
msg = first()
default:
// Build a format string so that it will be similar to Sprint
msg = fmt.Sprintf(fmt.Sprint(first)+strings.Repeat(" %v", len(args)), args...)
}
log.intLogf(lvl, msg)
return errors.New(msg)
}
func (log Logger) Info(arg0 interface{}, args ...interface{}) {
const (
lvl = INFO
)
switch first := arg0.(type) {
case string:
// Use the string as a format string
log.intLogf(lvl, first, args...)
case func() string:
// Log the closure (no other arguments used)
log.intLogc(lvl, first)
default:
// Build a format string so that it will be similar to Sprint
log.intLogf(lvl, fmt.Sprint(arg0)+strings.Repeat(" %v", len(args)), args...)
}
...ANSWER
Answered 2018-Jan-09 at 03:41The most likely explanation is that due to the fact that Logger.Warn
method returns an error
value, it was refactored to at first save the value it needs to log into variable msg
and then log it separately as well as return it as the error.
Logger.Info
, at the same time, logs the message as soon as it is possible because it is not required to return the message.
This seems to be the only difference in the way these functions work.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install log4go
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page