Add basic functionality tests

This commit is contained in:
Gustavo Cordova Avila
2024-04-11 12:35:30 -07:00
parent 5f58b0dc45
commit 9cb1e5d9af
2 changed files with 34 additions and 0 deletions

1
tests/config.nims Normal file
View File

@@ -0,0 +1 @@
switch("path", "$projectDir/../src")

33
tests/test1.nim Normal file
View File

@@ -0,0 +1,33 @@
import unittest
import ../src/logging
test "Emit logging messages":
var log = getLogger("main", {"extra1": "one", "extra2": "two"})
log.always "This is an info message"
test "Shorthand methods":
var log = getLogger("shorthand")
log.always("This should always appear")
log.fatal("Such a terrible thing, a FATAL error; bye?")
log.critical("The engines are at CRITICAL level!!")
log.error("Something went wrong, I caught an ERROR")
log.warning("This is your first WARNING, ok?")
log.warn("This is your second WARNING, ok?")
log.quiet("Something important, say it QUIET")
log.info("Some INFOrmational data")
log.noisy("Level is low enough that it's NOISY")
log.debug("I don't see this unless I'm DEBUGging")
log.trace("We're TRACEing the code as we speak")
test "Emit different levels":
var log = getLogger("levels")
for l in LogLevel:
log.write(l, "level example", {"log-level": $l})
test "Emit different formats":
var log = getLogger("formats")
for fmt in LogOutputFormat:
setLogOutputFormat(fmt)
log.always("format example", {"format": $fmt})
# Fin.