2022-12-10 12:53:24 +00:00
|
|
|
# Nimbus
|
|
|
|
# Copyright (c) 2022 Status Research & Development GmbH
|
|
|
|
# Licensed under either of
|
|
|
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
|
|
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or
|
|
|
|
# http://opensource.org/licenses/MIT)
|
|
|
|
# at your option. This file may not be copied, modified, or distributed except
|
|
|
|
# according to those terms.
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
import
|
2022-11-17 08:27:26 +00:00
|
|
|
chronicles,
|
|
|
|
"."/[config, transition]
|
|
|
|
|
|
|
|
# we are using chronicles LogLevel
|
|
|
|
# instead of our LogLevel
|
|
|
|
import types except LogLevel
|
2022-10-15 15:58:23 +00:00
|
|
|
|
|
|
|
template wrapException(body) =
|
|
|
|
when wrapExceptionEnabled:
|
|
|
|
try:
|
|
|
|
body
|
|
|
|
except T8NError as e:
|
|
|
|
stderr.writeLine(e.msg)
|
|
|
|
quit(e.exitCode.int)
|
|
|
|
except:
|
|
|
|
let e = getCurrentException()
|
|
|
|
stderr.writeLine($e.name & " : " & e.msg)
|
|
|
|
quit(QuitFailure)
|
|
|
|
else:
|
|
|
|
body
|
|
|
|
|
2022-11-17 08:27:26 +00:00
|
|
|
when defined(chronicles_runtime_filtering):
|
|
|
|
proc toLogLevel(v: int): LogLevel =
|
|
|
|
case v
|
|
|
|
of 1: LogLevel.ERROR
|
|
|
|
of 2: LogLevel.WARN
|
|
|
|
of 3: LogLevel.INFO
|
|
|
|
of 4: LogLevel.DEBUG
|
|
|
|
of 5: LogLevel.TRACE
|
|
|
|
else: LogLevel.NONE
|
|
|
|
|
|
|
|
proc setVerbosity(v: int) =
|
|
|
|
let level = v.toLogLevel
|
|
|
|
setLogLevel(level)
|
|
|
|
|
2022-10-15 15:58:23 +00:00
|
|
|
proc main() =
|
|
|
|
wrapException:
|
|
|
|
let conf = T8NConf.init()
|
2022-11-17 08:27:26 +00:00
|
|
|
when defined(chronicles_runtime_filtering):
|
|
|
|
setVerbosity(conf.verbosity)
|
2022-10-15 15:58:23 +00:00
|
|
|
var ctx = TransContext()
|
|
|
|
ctx.transitionAction(conf)
|
|
|
|
|
|
|
|
main()
|