diff --git a/tests/config.nims b/tests/config.nims new file mode 100644 index 0000000..80091ff --- /dev/null +++ b/tests/config.nims @@ -0,0 +1 @@ +switch("path", "$projectDir/../src") diff --git a/tests/test1.nim b/tests/test1.nim new file mode 100644 index 0000000..cd78c58 --- /dev/null +++ b/tests/test1.nim @@ -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.