Numbered log entries (#559)
* add numbered log entries (hack) * Changed from CLI argument to compiler define * Use uint64 for counting --------- Co-authored-by: gmega <giuliano.mega@gmail.com>
This commit is contained in:
parent
570a1f7b67
commit
fede106118
|
@ -24,7 +24,7 @@ jobs:
|
|||
name: Build and Push
|
||||
uses: ./.github/workflows/docker-reusable.yml
|
||||
with:
|
||||
nimflags: '-d:disableMarchNative -d:codex_enable_api_debug_peers=true -d:codex_enable_simulated_proof_failures'
|
||||
nimflags: '-d:disableMarchNative -d:codex_enable_api_debug_peers=true -d:codex_enable_simulated_proof_failures -d:codex_enable_log_counter=true'
|
||||
nat_ip_auto: true
|
||||
tag_latest: ${{ github.ref_name == github.event.repository.default_branch || startsWith(github.ref, 'refs/tags/') }}
|
||||
tag_suffix: dist-tests
|
||||
|
|
|
@ -42,6 +42,7 @@ export net, DefaultQuotaBytes, DefaultBlockTtl, DefaultBlockMaintenanceInterval,
|
|||
const
|
||||
codex_enable_api_debug_peers* {.booldefine.} = false
|
||||
codex_enable_proof_failures* {.booldefine.} = false
|
||||
codex_enable_log_counter* {.booldefine.} = false
|
||||
|
||||
type
|
||||
StartUpCommand* {.pure.} = enum
|
||||
|
@ -463,7 +464,7 @@ proc setupLogging*(conf: CodexConf) =
|
|||
|
||||
defaultChroniclesStream.outputs[1].writer = noOutput
|
||||
|
||||
defaultChroniclesStream.outputs[0].writer =
|
||||
let writer =
|
||||
case conf.logFormat:
|
||||
of LogKind.Auto:
|
||||
if isatty(stdout):
|
||||
|
@ -478,6 +479,16 @@ proc setupLogging*(conf: CodexConf) =
|
|||
of LogKind.None:
|
||||
noOutput
|
||||
|
||||
when codex_enable_log_counter:
|
||||
var counter = 0.uint64
|
||||
proc numberedWriter(logLevel: LogLevel, msg: LogOutputStr) =
|
||||
inc(counter)
|
||||
let withoutNewLine = msg[0..^2]
|
||||
writer(logLevel, withoutNewLine & " count=" & $counter & "\n")
|
||||
defaultChroniclesStream.outputs[0].writer = numberedWriter
|
||||
else:
|
||||
defaultChroniclesStream.outputs[0].writer = writer
|
||||
|
||||
try:
|
||||
updateLogLevel(conf.logLevel)
|
||||
except ValueError as err:
|
||||
|
|
Loading…
Reference in New Issue