Difference between revisions of "AdvLog"
From ESS-WIKI
Fred.chang (talk | contribs) |
Fred.chang (talk | contribs) |
||
Line 10: | Line 10: | ||
#Support remote control to change setting dynamically. | #Support remote control to change setting dynamically. | ||
− | |||
==C functions== | ==C functions== | ||
== Config File Format == | == Config File Format == |
Revision as of 10:26, 1 October 2018
Introduction
This logging library provides one sample way to log messages from application, and has many modern features which are listed below
- Showing on console and storing into storage in the same time.
- Be colorful and gradational to highlight information.
- Support two kinds of record format in text and HTML.
- Rolling file to avoid out of storage.
- Support three storage policies to limit the number of amount in folder, the number of file in current process and the size of current file.
- Support remote control to change setting dynamically.
C functions
Config File Format
Config file is in JSON Format:
{
"default": {
"static": {
"level": 5,
"information": 1
},
"dynamic": {
"level": 5,
"information": 0,
"hide": ""
},
"path": "./logs",
"files": 30,
"limit": 10240,
"number": 40
}
}
- [path]: set log files path (default:./logs)
- [files]: set the max existing file number of all the files in the log path (a.k.a amount) (default:100, min:30, max:200)
- [limit]: set the max rolling threshold byte of this process -------------- (unit: byte) (default:102400, min:10240)
- [number]: set the max rolling file number of this process ---------------- (a.k.a count) (default:2, min:2, max:20)
- [static/dynamic]: "static" means the settings of writing to log file. "dynamic" means the setting of display on console.
- [level]: Set log level (default:5)(negative means gray mode in dynamic and text mode in static),
- 1:Fatal
- 2:Error
- 3:Warning
- 4:Notice
- 5:Info(Normal)
- 7:Debug
- [information]: Enable DYNAMIC/STATIC Flag(default:0)
- 0: No timestamp;
- 1: Add timestamp
- [hide]:Hide DYNAMIC message (default:"", example:"1,3,5" to hide level 1, 3 and 5 message)
Output Log Format
Default output format is html file:
<!DOCTYPE html><html><head><style type="text/css">body{color:white;background-color:black}log{display:block;}red>script{color:red;background-color:black}red{color:red;background-color:black}green>script{color:green;background-color:black}green{color:green;background-color:black}yellow>script{color:yellow;background-color:black}yellow{color:yellow;background-color:black}blue>script{color:#1569C7;background-color:black}blue{color:#1569C7;background-color:black}purple>script{color:purple;background-color:black}purple{color:purple;background-color:black}cyan>script{color:cyan;background-color:black}cyan{color:cyan;background-color:black}gray{color:#1C1C1C;background-color:black}redbg>script{color:white;background-color:red}redbg{color:white;background-color:red}greenbg>script{color:white;background-color:green}greenbg{color:white;background-color:green}yellowbg>script{color:black;background-color:yellow}yellowbg{color:black;background-color:yellow}bluebg>script{color:white;background-color:blue}bluebg{color:white;background-color:blue}purplebg>script{color:white;background-color:purple}purplebg{color:white;background-color:purple}cyanbg>script{color:black;background-color:cyan}cyanbg{color:black;background-color:cyan}whitebg>script{color:black;background-color:white}whitebg{color:black;background-color:white}script{display:block;}</style></head><body><pre><log><code> general> Initialize
</code><gray> [2016/06/29 16:27:42] [INFO] (.\SAGeneralHandler.c,General_Initialize,327)</gray>
</log><log><script type="text/plain"> general>Recv Topic [/cagent/admin/0000000BAB4231C8/agentcallbackreq] Data {"susiCommData":{"commCmd":2051,"requestID":0,"agentID":"","handlerName":"general","sendTS":1467188865}}
</script><gray> [2016/06/29 16:27:45] [INFO] (.\SAGeneralHandler.c,General_HandleRecv,372)</gray>
</log><log><script type="text/plain"> general>Recv Topic [/cagent/admin/0000000BAB4231C8/agentcallbackreq] Data {"susiCommData":{"requestItems":{},"commCmd":2056,"requestID":0,"agentID":"","handlerName":"general","sendTS":1467188865}}
</script><gray> [2016/06/29 16:27:45] [INFO] (.\SAGeneralHandler.c,General_HandleRecv,372)</gray>
</log></pre></body></html>
and showed on browser as below.