mirror of
https://github.com/github/semantic.git
synced 2025-01-03 13:02:37 +03:00
Autodetect print source
This commit is contained in:
parent
ec9fcc7007
commit
da51cb3c20
@ -70,9 +70,9 @@ terminalFormatter Options{..} (Message level message pairs time) =
|
|||||||
data Options = Options
|
data Options = Options
|
||||||
{ optionsEnableColour :: Bool -- ^ Whether to enable colour formatting for logging (Only works when logging to a terminal that supports ANSI colors).
|
{ optionsEnableColour :: Bool -- ^ Whether to enable colour formatting for logging (Only works when logging to a terminal that supports ANSI colors).
|
||||||
, optionsLevel :: Maybe Level -- ^ What level of messages to log. 'Nothing' disabled logging.
|
, optionsLevel :: Maybe Level -- ^ What level of messages to log. 'Nothing' disabled logging.
|
||||||
, optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors.
|
|
||||||
, optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems.
|
, optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems.
|
||||||
, optionsIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime).
|
, optionsIsTerminal :: Bool -- ^ Whether a terminal is attached (set automaticaly at runtime).
|
||||||
|
, optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors (set automatically at runtime).
|
||||||
, optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime).
|
, optionsFormatter :: Options -> Message -> String -- ^ Log formatter to use (set automaticaly at runtime).
|
||||||
, optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime).
|
, optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime).
|
||||||
}
|
}
|
||||||
@ -81,9 +81,9 @@ defaultOptions :: Options
|
|||||||
defaultOptions = Options
|
defaultOptions = Options
|
||||||
{ optionsEnableColour = True
|
{ optionsEnableColour = True
|
||||||
, optionsLevel = Just Warning
|
, optionsLevel = Just Warning
|
||||||
, optionsPrintSource = False
|
|
||||||
, optionsRequestID = Nothing
|
, optionsRequestID = Nothing
|
||||||
, optionsIsTerminal = False
|
, optionsIsTerminal = False
|
||||||
|
, optionsPrintSource = False
|
||||||
, optionsFormatter = logfmtFormatter
|
, optionsFormatter = logfmtFormatter
|
||||||
, optionsProcessID = 0
|
, optionsProcessID = 0
|
||||||
}
|
}
|
||||||
@ -95,6 +95,7 @@ configureOptionsForHandle handle options = do
|
|||||||
pure $ options
|
pure $ options
|
||||||
{ optionsIsTerminal = isTerminal
|
{ optionsIsTerminal = isTerminal
|
||||||
, optionsFormatter = if isTerminal then terminalFormatter else logfmtFormatter
|
, optionsFormatter = if isTerminal then terminalFormatter else logfmtFormatter
|
||||||
|
, optionsPrintSource = isTerminal
|
||||||
, optionsProcessID = pid
|
, optionsProcessID = pid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,10 +44,10 @@ arguments = info (version <*> helper <*> ((,) <$> optionsParser <*> argumentsPar
|
|||||||
<$> (not <$> switch (long "disable-colour" <> long "disable-color" <> help "Disable ANSI colors in log messages even if the terminal is a TTY."))
|
<$> (not <$> switch (long "disable-colour" <> long "disable-color" <> help "Disable ANSI colors in log messages even if the terminal is a TTY."))
|
||||||
<*> options [("error", Just Log.Error), ("warning", Just Log.Warning), ("info", Just Log.Info), ("debug", Just Log.Debug), ("none", Nothing)]
|
<*> options [("error", Just Log.Error), ("warning", Just Log.Warning), ("info", Just Log.Info), ("debug", Just Log.Debug), ("none", Nothing)]
|
||||||
(long "log-level" <> value (Just Log.Warning) <> help "Log messages at or above this level, or disable logging entirely.")
|
(long "log-level" <> value (Just Log.Warning) <> help "Log messages at or above this level, or disable logging entirely.")
|
||||||
<*> switch (long "print-source" <> help "Include source references in logged errors where applicable.")
|
|
||||||
<*> optional (strOption (long "request-id" <> help "A string to use as the request identifier for any logged messages." <> metavar "id"))
|
<*> optional (strOption (long "request-id" <> help "A string to use as the request identifier for any logged messages." <> metavar "id"))
|
||||||
-- The rest of the logging options are set automatically at runtime.
|
-- The rest of the logging options are set automatically at runtime.
|
||||||
<*> pure False -- IsTerminal
|
<*> pure False -- IsTerminal
|
||||||
|
<*> pure False -- PrintSource
|
||||||
<*> pure Log.logfmtFormatter -- Formatter
|
<*> pure Log.logfmtFormatter -- Formatter
|
||||||
<*> pure 0 -- ProcessID
|
<*> pure 0 -- ProcessID
|
||||||
argumentsParser = (. Task.writeToOutput) . (>>=)
|
argumentsParser = (. Task.writeToOutput) . (>>=)
|
||||||
|
Loading…
Reference in New Issue
Block a user