diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..378eac2 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..9f17d2b --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,22 @@ +Copyright 2025 Antranig Vartanian. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this +list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation and/or +other materials provided with the distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/tests/LoggerTest.Mod b/tests/LoggerTest.Mod index 04e8c7f..2477f4f 100644 --- a/tests/LoggerTest.Mod +++ b/tests/LoggerTest.Mod @@ -11,20 +11,20 @@ BEGIN (* Show default level (INFO) in action *) log.Info("Logger initialized"); - log.InfoInt("Connected users: ", 42); + log.InfoInt("The answer to life, the universe, and everything: ", 42); (* Prefix usage *) - log.SetPrefix("unit-test"); - log.Warn("Warning with prefix"); - log.WarnInt("Sessions: ", 5); + log.SetPrefix("Web Server"); + log.Warn("Web Server is loading slowly"); + log.WarnInt("Current threads: ", 4); - log.Error("Something went wrong"); - log.ErrorInt("Error code: ", -7); + log.Error("Something went wrong..."); + log.ErrorInt("The function returned: ", -1); (* Switch to DEBUG level *) log.SetLevel(Logger.DEBUG); log.Debug("This is a debug message"); - log.DebugInt("File descriptor: ", 3); + log.DebugInt("File descriptor: ", 73); (* Clear prefix *) log.ClearPrefix(); diff --git a/tests/expected.txt b/tests/expected.txt index 83d5d64..3051304 100644 --- a/tests/expected.txt +++ b/tests/expected.txt @@ -1,9 +1,9 @@ -[2025-06-15T03:27:27Z] [INFO] Logger initialized -[2025-06-15T03:27:27Z] [INFO] Connected users: 42 -[2025-06-15T03:27:27Z] [WARN] [unit-test] Warning with prefix -[2025-06-15T03:27:27Z] [WARN] [unit-test] Sessions: 5 -[2025-06-15T03:27:27Z] [ERROR] [unit-test] Something went wrong -[2025-06-15T03:27:27Z] [ERROR] [unit-test] Error code: -7 -[2025-06-15T03:27:27Z] [DEBUG] [unit-test] This is a debug message -[2025-06-15T03:27:27Z] [DEBUG] [unit-test] File descriptor: 3 -[2025-06-15T03:27:27Z] [INFO] Prefix cleared +[2025-06-15T04:02:43Z] [INFO] Logger initialized +[2025-06-15T04:02:43Z] [INFO] The answer to life, the universe, and everything: 42 +[2025-06-15T04:02:43Z] [WARN] [Web Server] Web Server is loading slowly +[2025-06-15T04:02:43Z] [WARN] [Web Server] Current threads: 4 +[2025-06-15T04:02:43Z] [ERROR] [Web Server] Something went wrong... +[2025-06-15T04:02:43Z] [ERROR] [Web Server] The function returned: -1 +[2025-06-15T04:02:43Z] [DEBUG] [Web Server] This is a debug message +[2025-06-15T04:02:43Z] [DEBUG] [Web Server] File descriptor: 73 +[2025-06-15T04:02:43Z] [INFO] Prefix cleared