This repository has been archived by the owner on Aug 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 629
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3609 from input-output-hk/andreas/CBR-423/Structu…
…red-logging-of-data-structures_PR [CBR-423] Structured logging of data structures
- Loading branch information
Showing
10 changed files
with
367 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
module Pos.Util.Log.Structured | ||
( logMessageX | ||
, logDebugX | ||
, logInfoX | ||
, logNoticeX | ||
, logWarningX | ||
, logErrorX | ||
-- * Safe logging | ||
, logMessageSX | ||
, logDebugSX | ||
, logInfoSX | ||
, logNoticeSX | ||
, logWarningSX | ||
, logErrorSX | ||
, logMessagePX | ||
, logDebugPX | ||
, logInfoPX | ||
, logNoticePX | ||
, logWarningPX | ||
, logErrorPX | ||
) where | ||
|
||
import Universum | ||
|
||
import Pos.Util.Log (ToObject) | ||
import Pos.Util.Log.LogSafe (selectPublicLogs, selectSecretLogs) | ||
import Pos.Util.Wlog.Compatibility (HasLoggerName (..), Severity (..), | ||
logMX, logXCond) | ||
|
||
-- | Shortcut for 'logMessageX' to use according severity. | ||
logDebugX, logInfoX, logNoticeX, logWarningX, logErrorX | ||
:: (HasLoggerName m, MonadIO m, ToObject a) | ||
=> a -> m () | ||
logDebugX = logMessageX Debug | ||
logInfoX = logMessageX Info | ||
logNoticeX = logMessageX Notice | ||
logWarningX = logMessageX Warning | ||
logErrorX = logMessageX Error | ||
|
||
-- | Log an item in JSON format (only for JSON scribes). | ||
logMessageX | ||
:: (HasLoggerName m, MonadIO m, ToObject a) | ||
=> Severity | ||
-> a | ||
-> m () | ||
logMessageX severity a = do | ||
name <- askLoggerName | ||
logMX name severity a | ||
|
||
-- | Shortcut for 'logMessageSX' to use according severity. | ||
logDebugSX, logInfoSX, logNoticeSX, logWarningSX, logErrorSX | ||
:: (HasLoggerName m, MonadIO m, ToObject a) | ||
=> a -> m () | ||
logDebugSX = logMessageSX Debug | ||
logInfoSX = logMessageSX Info | ||
logNoticeSX = logMessageSX Notice | ||
logWarningSX = logMessageSX Warning | ||
logErrorSX = logMessageSX Error | ||
|
||
-- | Log an item in JSON format (only for secret JSON scribes). | ||
logMessageSX | ||
:: (HasLoggerName m, MonadIO m, ToObject a) | ||
=> Severity | ||
-> a | ||
-> m () | ||
logMessageSX severity a = do | ||
name <- askLoggerName | ||
logXCond name severity a selectSecretLogs | ||
|
||
-- | Shortcut for 'logMessagePX' to use according severity. | ||
logDebugPX, logInfoPX, logNoticePX, logWarningPX, logErrorPX | ||
:: (HasLoggerName m, MonadIO m, ToObject a) | ||
=> a -> m () | ||
logDebugPX = logMessagePX Debug | ||
logInfoPX = logMessagePX Info | ||
logNoticePX = logMessagePX Notice | ||
logWarningPX = logMessagePX Warning | ||
logErrorPX = logMessagePX Error | ||
|
||
-- | Log an item in JSON format (only for public JSON scribes). | ||
logMessagePX | ||
:: (HasLoggerName m, MonadIO m, ToObject a) | ||
=> Severity | ||
-> a | ||
-> m () | ||
logMessagePX severity a = do | ||
name <- askLoggerName | ||
logXCond name severity a selectPublicLogs |
Oops, something went wrong.