casual_logger
A logger used when practicing the sample programs.
Only write to file, rotate by date.
Not for hard users.
At first, Disclaim
- It differs from the standard Rust log interface.
- Ignore performance for ease of use.
At second, Overall view
Your code:
use ;
Output ./default-2020-07-12.log.toml
auto generated:
[]
= "Remove file count=0\r\n"
[]
= """
Hello, world!!
こんにちわ、世界!!\r\n
"""
[]
= "x is 100.\r\n"
[]
= "A,"
[]
= "B,\r\n"
[]
= "C,"
[]
= "D,\r\n"
[]
= "E,"
[]
= "F,\r\n"
[]
= "G,"
[]
= "H,\r\n"
[]
= "I,"
[]
= "J,\r\n"
[]
= "K,"
[]
= "L,\r\n"
[]
= "M,"
[]
= "N!\r\n"
At third, Description
Code:
use ;
At the timing of the first writing, a file with a
time stamp in its name is automatically generated.
For example: ./tic-tac-toe-2020-07-12.log.toml
Description:
./
- Working directory only.tic-tac-toe
- Prefix. Editable. Default:default
.-2020-07-12
- StartDate. Auto generated..log
- Suffix. Editable. Default:.log
.
Suffix to be safe, include a word that
clearly states that you can delete the file.
.toml
- Extension. Editable. Default:.toml
.
If you don't like the .toml extension, leave
the suffix empty and the .log extension.
Set up, Code:
Description of retention_days:
- For example,
retention_days
is 2. Default:7
. - Today is 2020-07-12.
- The
./default-2020-07-09.log.toml
file will be deleted. - The
./default-2020-07-10.log.toml
remains. - Delete old files by date in filename.
Description of level:
- There are 7 log levels. Default:
Trace
.Fatal < Error < Warn < Notice < Info < Debug < Trace
.
- Example:
Log::info("Hello, world!!");
Log::infoln("Hello, world!!");
if Log::enabled(Level::Info) {Log::infoln("Hello!");}
Code:
;
if enabled
trace;
traceln;
debug;
debugln;
info;
infoln;
notice;
noticeln;
warn;
warnln;
error;
errorln;
fatal;
fatalln;
infoln
TODO
- Adding table items as toml.
Tested environment
- OS:
Windows 10
. - Editor:
Visual studio code
.