|
|
@ -4,7 +4,7 @@ import docopt, timeutils, zero_functional
|
|
|
|
from std/logging import Level
|
|
|
|
from std/logging import Level
|
|
|
|
from std/sequtils import toSeq
|
|
|
|
from std/sequtils import toSeq
|
|
|
|
|
|
|
|
|
|
|
|
const VERSION = "0.2.1"
|
|
|
|
const VERSION = "0.2.3"
|
|
|
|
|
|
|
|
|
|
|
|
const USAGE = """Usage:
|
|
|
|
const USAGE = """Usage:
|
|
|
|
slfmt [options]
|
|
|
|
slfmt [options]
|
|
|
@ -63,7 +63,7 @@ proc fullFormatField(name: string, value: JsonNode): string =
|
|
|
|
else: strVal = pretty(value)
|
|
|
|
else: strVal = pretty(value)
|
|
|
|
|
|
|
|
|
|
|
|
let valLines = splitLines(strVal)
|
|
|
|
let valLines = splitLines(strVal)
|
|
|
|
if name.len > 10 or strVal.len + 16 > terminalWidth() or valLines.len > 1:
|
|
|
|
if name.len + strVal.len + 6 > terminalWidth() or valLines.len > 1:
|
|
|
|
result &= "\n" & valLines.mapIt(" " & it).join("\n") & "\n"
|
|
|
|
result &= "\n" & valLines.mapIt(" " & it).join("\n") & "\n"
|
|
|
|
else: result &= strVal & "\n"
|
|
|
|
else: result &= strVal & "\n"
|
|
|
|
|
|
|
|
|
|
|
@ -98,14 +98,21 @@ proc compactFormat(logJson: JsonNode): string =
|
|
|
|
filter(not ["level", "scope", "ts", "msg"].contains(it[0]))
|
|
|
|
filter(not ["level", "scope", "ts", "msg"].contains(it[0]))
|
|
|
|
|
|
|
|
|
|
|
|
let restMsg = join(restNodes -->
|
|
|
|
let restMsg = join(restNodes -->
|
|
|
|
map("$1: $2" % [decorate(it[0], fgCyan), it[1].getStr]), " ")
|
|
|
|
map("$1: $2" % [
|
|
|
|
|
|
|
|
decorate(it[0], fgCyan),
|
|
|
|
|
|
|
|
if it[1].kind == JString: it[1].getStr
|
|
|
|
|
|
|
|
else: pretty(it[1]),
|
|
|
|
|
|
|
|
" "]))
|
|
|
|
|
|
|
|
|
|
|
|
if restMsg.len + result.len + 2 < terminalWidth():
|
|
|
|
if restMsg.len + result.len + 2 < terminalWidth():
|
|
|
|
result &= " " & restMsg
|
|
|
|
result &= " " & restMsg
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
var line = " "
|
|
|
|
var line = " "
|
|
|
|
for (key, val) in restNodes:
|
|
|
|
for (key, val) in restNodes:
|
|
|
|
let field = "$1: $2" % [decorate(key, fgCyan), val.getStr]
|
|
|
|
let fieldVal =
|
|
|
|
|
|
|
|
if val.kind == JString: val.getStr
|
|
|
|
|
|
|
|
else: pretty(val)
|
|
|
|
|
|
|
|
let field = "$1: $2" % [decorate(key, fgCyan), fieldVal]
|
|
|
|
if line.len + field.len + 2 > terminalWidth():
|
|
|
|
if line.len + field.len + 2 > terminalWidth():
|
|
|
|
result &= "\n " & line
|
|
|
|
result &= "\n " & line
|
|
|
|
line = " "
|
|
|
|
line = " "
|
|
|
|