|
|
@ -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.0"
|
|
|
|
const VERSION = "0.2.2"
|
|
|
|
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
|
|
|
|
|
|
@ -134,6 +134,8 @@ when isMainModule:
|
|
|
|
while(sin.readLine(line)):
|
|
|
|
while(sin.readLine(line)):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
let logJson = parseLogLine(line)
|
|
|
|
let logJson = parseLogLine(line)
|
|
|
|
|
|
|
|
if logJson.kind != JObject:
|
|
|
|
|
|
|
|
raise newException(JsonParsingError, "Expected a JSON object")
|
|
|
|
|
|
|
|
|
|
|
|
if logLevel.isSome and logJson.hasKey("level"):
|
|
|
|
if logLevel.isSome and logJson.hasKey("level"):
|
|
|
|
let lvl = parseLogLevel(logJson["level"].getStr)
|
|
|
|
let lvl = parseLogLevel(logJson["level"].getStr)
|
|
|
|