diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a6fa25..01a0229 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## [v0.4.0](https://git.zhirov.kz/dlang/singlog/compare/v0.3.2...v0.4.0) (2023.06.07) +- Part of the code has been changed/rewritten + ### New - Color output of messages to the terminal and console diff --git a/README.md b/README.md index ea34a40..0a36762 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ Setting the name of the logged program (it matters for Windows OS): log.program("My program"); ``` -Color output setting (`false` by default): +Setting the status of color text output (`false` by default): ```d log.color(true); diff --git a/dub.json b/dub.json index 97549a7..1ab2258 100644 --- a/dub.json +++ b/dub.json @@ -18,7 +18,7 @@ "name": "test", "targetType": "executable", "targetPath": "bin", - "targetName": "app", + "targetName": "test", "importPaths": ["source","tests"], "sourcePaths": ["tests"] } diff --git a/source/singlog.d b/source/singlog.d index ace5dd1..5caa979 100644 --- a/source/singlog.d +++ b/source/singlog.d @@ -50,7 +50,7 @@ class Log { private: static Log _log; string _path; - string _name = "singlog"; + wstring _name = "singlog"; bool _writeToFile = true; bool _ccolor = false; @@ -69,7 +69,7 @@ version(Windows) { void writesyslog(string message, WORD priority) { import std.utf: toUTF16z; auto wMessage = message.toUTF16z(); - HANDLE handleEventLog = RegisterEventSourceA(NULL, this._name.toStringz()); + HANDLE handleEventLog = RegisterEventSourceW(NULL, this._name.ptr); if (handleEventLog == NULL) return; @@ -79,13 +79,13 @@ version(Windows) { } WORD[] _color = [ - FOREGROUND_GREEN, - FOREGROUND_BLUE, - FOREGROUND_RED | FOREGROUND_BLUE, - FOREGROUND_RED, - FOREGROUND_RED | FOREGROUND_GREEN, - FOREGROUND_BLUE | FOREGROUND_GREEN, - FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN + FOREGROUND_GREEN, // green + FOREGROUND_BLUE, // blue + FOREGROUND_RED | FOREGROUND_BLUE, // magenta + FOREGROUND_RED, // red + FOREGROUND_RED | FOREGROUND_GREEN, // yellow + FOREGROUND_BLUE | FOREGROUND_GREEN, // cyan + FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_GREEN // white ]; void colorTextOutput(string time, wstring message, int priority) { @@ -241,7 +241,7 @@ public: } Log output(int outs) { this._output = outs; return this._log; } - Log program(string name) { this._name = name; return this._log; } + Log program(string name) { this._name = name.to!wstring; return this._log; } Log file(string path) { this._path = path; return this._log; } Log level(int priority) { this._priority = priority; return this._log; } Log color(bool condition) { this._ccolor = condition; return this._log; }