diff --git a/CHANGELOG.md b/CHANGELOG.md index 347204d..f6bd7b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [v0.3.0](https://git.zhirov.kz/dlang/singlog/compare/v0.2.1...v0.3.0) (2023.04.28) +- Minor changes + ### New - Windows OS Logging support diff --git a/README.md b/README.md index 13e4d74..c81f8a5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# singlog +![singlog](singlog.png) [![license](https://img.shields.io/github/license/AlexanderZhirov/singlog.svg?sort=semver&style=for-the-badge&color=green)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) [![main](https://img.shields.io/badge/dynamic/json.svg?label=git.zhirov.kz&style=for-the-badge&url=https://git.zhirov.kz/api/v1/repos/dlang/singlog/tags&query=$[0].name&color=violet)](https://git.zhirov.kz/dlang/singlog) @@ -14,14 +14,16 @@ Singleton for simple logging ```d import singlog; -void main() -{ - log.level(log.DEBUG); - // write to syslog and file - log.output(log.SYSLOG | log.FILE); - log.file("./file.log"); - log.warning("Hello, World!"); - log.w("The same thing"); +void main(string[] argv) { + log.output(log.SYSLOG | log.STDOUT | log.FILE) // write to syslog, standard output stream and file + .name(argv[0]) // program name as an identifier (for Windows OS) + .level(log.DEBUGGING) // logging level + .file("./test.log"); // the path to the log file + + log.e("This is an error message"); + log.error("And this is also an error message"); + log.w("This is a warning message"); + log.i("This is an information message"); } ``` diff --git a/dub.json b/dub.json index a2c64ed..97549a7 100644 --- a/dub.json +++ b/dub.json @@ -7,8 +7,6 @@ "license": "GPL-2.0", "copyright": "© Alexander Zhirov, 2023", "description": "Singleton for simple logging", - "targetType": "library", - "targetPath": "lib", "targetName": "singlog", "configurations": [ { diff --git a/singlog.png b/singlog.png new file mode 100644 index 0000000..966037c Binary files /dev/null and b/singlog.png differ diff --git a/source/singlog.d b/source/singlog.d index 717c1a6..20aa256 100644 --- a/source/singlog.d +++ b/source/singlog.d @@ -124,9 +124,7 @@ version(Windows) { if (!this.writeToFile) return; - if (this.path.exists) - this.writeToFile = true; - else { + if (!this.path.exists) { this.writeToFile = false; this.warning("The log file does not exist: " ~ this.path); } diff --git a/tests/test.d b/tests/test.d index ad4fd32..d272174 100644 --- a/tests/test.d +++ b/tests/test.d @@ -1,11 +1,13 @@ import singlog; void main(string[] argv) { - log.output(log.SYSLOG | log.STDOUT | log.FILE) - .name(argv[0]) - .level(Log.DEBUGGING) - .file("./test.log"); - log.e("hello!"); - log.w("hello!"); - log.i("hello!"); + log.output(log.SYSLOG | log.STDOUT | log.FILE) // write to syslog, standard output stream and file + .name(argv[0]) // program name as an identifier (for Windows OS) + .level(log.DEBUGGING) // logging level + .file("./test.log"); // the path to the log file + + log.e("This is an error message"); + log.error("And this is also an error message"); + log.w("This is a warning message"); + log.i("This is an information message"); }