@@ -12,8 +12,9 @@ import Cardano.Logging.Types
1212import Data.Aeson hiding (Error )
1313import Data.ByteString.Lazy (toStrict )
1414import qualified Data.Map as Map
15- import Data.Text
16- import Data.Text.Encoding
15+ import Data.Text (Text )
16+ import qualified Data.Text as Text
17+ import qualified Data.Text.Encoding as Text
1718
1819data UnknownNamespaceKind =
1920 UKFSeverity
@@ -51,20 +52,20 @@ data TraceDispatcherMessage =
5152instance LogFormatting TraceDispatcherMessage where
5253 forHuman (StartLimiting txt) = " Start of frequency limiting for " <> txt
5354 forHuman (StopLimiting txt num) = " Stop of frequency limiting for " <> txt <>
54- " . Suppressed " <> pack ( show num) <> " messages."
55+ " . Suppressed " <> textShow num <> " messages."
5556 forHuman (RememberLimiting txt num) = " Frequency limiting still active for " <> txt <>
56- " . Suppressed so far " <> pack ( show num) <> " messages."
57+ " . Suppressed so far " <> textShow num <> " messages."
5758 forHuman (UnknownNamespace nsPrefixNS nsInnerNS qk) = " Unknown namespace detected "
58- <> intercalate (singleton ' .' ) (nsPrefixNS ++ nsInnerNS)
59- <> " . Used for querying " <> (pack . show ) qk <> " ."
59+ <> Text. intercalate (Text. singleton ' .' ) (nsPrefixNS ++ nsInnerNS)
60+ <> " . Used for querying " <> textShow qk <> " ."
6061 forHuman (TracerInfo silent noMetrics allTracers) = " The tracing system has silent the following tracer,"
6162 <> " as they will never have any output according to the current config: "
62- <> intercalate (singleton ' ' ) silent <> " . The following tracers will not emit metrics "
63- <> intercalate (singleton ' ' ) noMetrics <> " . Here is a complete list of all tracers: "
64- <> intercalate (singleton ' ' ) allTracers <> " ."
65- forHuman (MetricsInfo mmap) = " Number of metrics delivered, " <> (pack . show ) mmap
66- forHuman (TracerConsistencyWarnings errs) = " Consistency check found error: " <> (pack . show ) errs
67- forHuman (TracerInfoConfig tc) = " Effective Tracer config is: " <> decodeUtf8 (toStrict (encode tc))
63+ <> Text. intercalate (Text. singleton ' ' ) silent <> " . The following tracers will not emit metrics "
64+ <> Text. intercalate (Text. singleton ' ' ) noMetrics <> " . Here is a complete list of all tracers: "
65+ <> Text. intercalate (Text. singleton ' ' ) allTracers <> " ."
66+ forHuman (MetricsInfo mmap) = " Number of metrics delivered, " <> textShow mmap
67+ forHuman (TracerConsistencyWarnings errs) = " Consistency check found error: " <> textShow errs
68+ forHuman (TracerInfoConfig tc) = " Effective Tracer config is: " <> Text. decodeUtf8 (toStrict (encode tc))
6869
6970
7071 forMachine _dtl StartLimiting {} = mconcat
@@ -80,23 +81,23 @@ instance LogFormatting TraceDispatcherMessage where
8081 ]
8182 forMachine _dtl (UnknownNamespace nsun nsleg query) = mconcat
8283 [ " kind" .= String " UnknownNamespace"
83- , " unknownNamespace" .= String (intercalate (singleton ' .' ) nsun)
84- , " legalNamespace" .= String (intercalate (singleton ' .' ) nsleg)
85- , " querying" .= String ((pack . show ) query)
84+ , " unknownNamespace" .= String (Text. intercalate (Text. singleton ' .' ) nsun)
85+ , " legalNamespace" .= String (Text. intercalate (Text. singleton ' .' ) nsleg)
86+ , " querying" .= String (textShow query)
8687 ]
8788 forMachine _dtl (TracerInfo silent noMetrics allTracers) = mconcat
8889 [ " kind" .= String " TracerMeta"
89- , " silentTracers" .= String (intercalate (singleton ' ' ) silent)
90- , " noMetrics" .= String (intercalate (singleton ' ' ) noMetrics)
91- , " allTracers" .= String (intercalate (singleton ' ' ) allTracers)
90+ , " silentTracers" .= String (Text. intercalate (Text. singleton ' ' ) silent)
91+ , " noMetrics" .= String (Text. intercalate (Text. singleton ' ' ) noMetrics)
92+ , " allTracers" .= String (Text. intercalate (Text. singleton ' ' ) allTracers)
9293 ]
9394 forMachine _dtl (MetricsInfo mmap) = mconcat
9495 [ " kind" .= String " MetricsInfo"
95- , " metrics count" .= String ((pack . show ) mmap)
96+ , " metrics count" .= String (textShow mmap)
9697 ]
9798 forMachine _dtl (TracerConsistencyWarnings errs) = mconcat
9899 [ " kind" .= String " TracerConsistencyWarnings"
99- , " errors" .= String ((pack . show ) errs)
100+ , " errors" .= String (textShow errs)
100101 ]
101102 forMachine _dtl (TracerInfoConfig tc) = mconcat
102103 [ " conf" .= toJSON tc
@@ -182,3 +183,8 @@ instance MetaTrace TraceDispatcherMessage where
182183 , Namespace [] [" TracerConsistencyWarnings" ]
183184 , Namespace [] [" TracerConfigInfo" ]
184185 ]
186+
187+ -- `text-2.1.2` provides `Text.show` which can replace this when
188+ -- the lower bound for `text` is high enough.
189+ textShow :: Show a => a -> Text
190+ textShow = Text. pack . show
0 commit comments