Compare commits

..

No commits in common. "5dd910b683c701d3d3590de799996aef35d8558e" and "06784491cdde7226f15c754fd691909af8e61df2" have entirely different histories.

4 changed files with 10 additions and 19 deletions

View File

@ -1,10 +1,5 @@
# Changelog # Changelog
## [v0.3.2](https://git.zhirov.kz/dlang/singlog/compare/v0.3.1...v0.3.2) (2023.06.01)
- Printing information about the type of the logged message to the standard output stream and file
- Printing the date and time to the standard output stream
## [v0.3.1](https://git.zhirov.kz/dlang/singlog/compare/v0.3.0...v0.3.1) (2023.05.30) ## [v0.3.1](https://git.zhirov.kz/dlang/singlog/compare/v0.3.0...v0.3.1) (2023.05.30)
### Bug fixes ### Bug fixes

View File

@ -27,8 +27,6 @@ void main(string[] argv) {
} }
``` ```
![output](tests/output.png)
## Examples ## Examples
Setting the name of the logged program (it matters for Windows OS): Setting the name of the logged program (it matters for Windows OS):
@ -77,4 +75,4 @@ log.d("Debugging message") => log.debugging("Debugging message");
## DUB ## DUB
Add a dependency on `"singlog": "~>0.3.2"`. Add a dependency on `"singlog": "~>0.3.1"`.

View File

@ -109,13 +109,11 @@ version(Windows) {
int msgOutput = STDOUT; int msgOutput = STDOUT;
int msgLevel = INFORMATION; int msgLevel = INFORMATION;
void writeLog(string message, string type, int msgLevel) { void writeLog(string message, int msgLevel) {
if (this.msgLevel > msgLevel) if (this.msgLevel > msgLevel)
return; return;
if (this.msgOutput & 1) if (this.msgOutput & 1)
syslog(sysLevel[msgLevel], message.toStringz()); syslog(sysLevel[msgLevel], message.toStringz());
if (this.msgOutput & 6)
message = format("%s [%s]: %s", Clock.currTime().format("%Y.%m.%d %H:%M:%S"), type, message);
if (this.msgOutput & 2) if (this.msgOutput & 2)
writeln(message); writeln(message);
if (this.msgOutput & 4) if (this.msgOutput & 4)
@ -144,7 +142,7 @@ version(Windows) {
} }
try { try {
file.writeln(message); file.writeln(Clock.currTime().format("%Y.%m.%d %H:%M:%S: ") ~ message);
} catch (Exception e) { } catch (Exception e) {
this.writeToFile = false; this.writeToFile = false;
this.error("Unable to write to the log file " ~ this.path); this.error("Unable to write to the log file " ~ this.path);
@ -175,13 +173,13 @@ public:
Log file(string path) { this.path = path; return this.log; } Log file(string path) { this.path = path; return this.log; }
Log level(int msgLevel) { this.msgLevel = msgLevel; return this.log; } Log level(int msgLevel) { this.msgLevel = msgLevel; return this.log; }
void alert(T)(T message) { writeLog(message.to!string, "ALERT", ALERT); } void alert(T)(T message) { writeLog(message.to!string, ALERT); }
void critical(T)(T message) { writeLog(message.to!string, "CRITICAL", CRITICAL); } void critical(T)(T message) { writeLog(message.to!string, CRITICAL); }
void error(T)(T message) { writeLog(message.to!string, "ERROR", ERROR); } void error(T)(T message) { writeLog(message.to!string, ERROR); }
void warning(T)(T message) { writeLog(message.to!string, "WARNING", WARNING); } void warning(T)(T message) { writeLog(message.to!string, WARNING); }
void notice(T)(T message) { writeLog(message.to!string, "NOTICE", NOTICE); } void notice(T)(T message) { writeLog(message.to!string, NOTICE); }
void information(T)(T message) { writeLog(message.to!string, "INFORMATION", INFORMATION); } void information(T)(T message) { writeLog(message.to!string, INFORMATION); }
void debugging(T)(T message) { writeLog(message.to!string, "DEBUGGING", DEBUGGING); } void debugging(T)(T message) { writeLog(message.to!string, DEBUGGING); }
alias a = alert; alias a = alert;
alias c = critical; alias c = critical;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 22 KiB