nxlog4go Simplest: Using for Testing Environment
nxlog4go is very simple to use without any configuring, setting. For example:
package main
import (
"time"
log "github.com/ccpaging/nxlog4go"
)
func main() {
log.Fine("This should be omitted as default.")
log.Debug("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
log.Info("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
log.Warn("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
log.Critical("The time is now: %s", time.Now().Format("15:04:05 MST 2006/01/02"))
}
Compatibility with go log
The most programmer always use go log for testing. nxlog4go aimed the replacement of go log.
Log Function | Level | After |
---|---|---|
Crash, Crashf | CRITICAL, panic | panic |
Exit, Exitf | ERROR, exit | exit |
Stderr, Stderrf | ERROR | |
Stdout, Stdoutf | INFO |
New log functions
Log Function | Level | Default |
---|---|---|
Finest(...) | 0 | Omit |
Fine(...) | 1 | Omit |
Debug(...) | 2 | |
Trace(...) | 3 | |
Info(...) | 4 | |
Warn(...) | 5 | |
Error(...) | 6 | |
Critical(...) | 7 |
Set display level
For example:
log.GetLogger().SetLevel(log.FINE)
log.Fine("This should be not omitted now.")
log.GetLogger() return the point of default Global Logger.
SetLevel(log.FINE) sets level to log.FINE.
更多原創文章乾貨分享,請關注公眾號
- 加微信實戰群請加微信(註明:實戰群):gocnio
相關文章
- Chapter 8 The Simplest Plug-in SolutionAPT
- Using Oracle Database 11g Release 2 Result Cache in an Oracle RAC EnvironmentOracleDatabase
- Using Real Application Testing Functionality in Earlier Releases_560977.1APPFunction
- nxlog4go 的配置驅動Go
- Testing
- 論文翻譯:2018_Source localization using deep neural networks in a shallow water environment
- ORA-31626 ORA-31650 While Using DataPump Export in RAC Environment [ID 454639.1]WhileExport
- Oracle environment variableOracle
- [Bash] Environment variables
- Exception testingException
- Get Oracle Environment InformaticaOracleORM
- Microsoft IT Environment Health ScannerROS
- The DB2 environmentDB2
- MyBatis-03-environmentMyBatis
- Unit testing frameworkFramework
- Database Unit TestingDatabase
- google friendly testingGo
- Spring系列.Environment介面Spring
- Setup python virtual environmentPython
- Quickly setup a stream environment.UI
- set up the appropriate environmentAPP
- swiftUI-@Environment的作用SwiftUI
- error: externally-managed-environmentError
- Android testing toolsAndroid
- Oracle Performance Testing PrincipleOracleORM
- Approaches to Performance TestingAPPORM
- Qt QML之 JavaScript Host EnvironmentQTJavaScript
- Change the Archiving Mode in a RAC Environment
- 配好 Europa C++ EnvironmentC++
- Restaurant Testing Round #12 BREST
- Testing the Modern Mobile World - AngLi
- nxlog4go 按天或按檔案大小分割日誌Go
- ERROR FIX:- rpmdb: unable to join the environmentError
- Materialized Views in data warehouse environment (185)ZedView
- Linux: Desktop Environment DE GUILinuxGUI
- CS540 Python Virtual EnvironmentPython
- Using index condition Using indexIndex
- Testing on the Toilet:不要濫用MockMock