Skip to content

Commit

Permalink
Simplify log formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
tbidne committed May 24, 2024
1 parent 158fe6a commit c6e0d99
Showing 1 changed file with 16 additions and 23 deletions.
39 changes: 16 additions & 23 deletions src/Shrun/Logging/Formatting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -149,30 +149,23 @@ coreFormatting ::
Log ->
Text
coreFormatting mLineTrunc mCommandNameTrunc stripControl keyHide log =
let line = case log ^. #cmd of
Nothing ->
let totalPrefix = brackets True logPrefix
in concatWithLineTrunc
mLineTrunc
totalPrefix
msgStripped
Just cmd ->
let cmd' =
formatCommand
keyHide
mCommandNameTrunc
cmd
totalPrefix =
mconcat
[ brackets False logPrefix,
cmd'
]
in concatWithLineTrunc
mLineTrunc
totalPrefix
msgStripped
in line
concatWithLineTrunc mLineTrunc prefix msgStripped
where
-- prefix is something like "[Success] " or "[Command][some cmd] ".
-- Notice this does not include ANSI codes or a timestamp.
prefix = case log ^. #cmd of
Nothing -> brackets True logPrefix
Just cmd ->
let cmd' =
formatCommand
keyHide
mCommandNameTrunc
cmd
in mconcat
[ brackets False logPrefix,
cmd'
]

msgStripped = stripChars (log ^. #msg) stripControl
logPrefix = logToPrefix log

Expand Down

0 comments on commit c6e0d99

Please sign in to comment.