Add basic functionality tests
This commit is contained in:
1
tests/config.nims
Normal file
1
tests/config.nims
Normal file
@@ -0,0 +1 @@
|
||||
switch("path", "$projectDir/../src")
|
||||
33
tests/test1.nim
Normal file
33
tests/test1.nim
Normal 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.
|
||||
Reference in New Issue
Block a user