diff --git a/src/Semantic/Log.hs b/src/Semantic/Log.hs index 466e59bb2..79c4cf48c 100644 --- a/src/Semantic/Log.hs +++ b/src/Semantic/Log.hs @@ -70,9 +70,9 @@ terminalFormatter Options{..} (Message level message pairs time) = data Options = Options { 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. - , optionsPrintSource :: Bool -- ^ Whether to print the source reference when logging errors. , optionsRequestID :: Maybe String -- ^ Optional request id for tracing across systems. , 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). , optionsProcessID :: CPid -- ^ ProcessID (set automaticaly at runtime). } @@ -81,9 +81,9 @@ defaultOptions :: Options defaultOptions = Options { optionsEnableColour = True , optionsLevel = Just Warning - , optionsPrintSource = False , optionsRequestID = Nothing , optionsIsTerminal = False + , optionsPrintSource = False , optionsFormatter = logfmtFormatter , optionsProcessID = 0 } @@ -95,6 +95,7 @@ configureOptionsForHandle handle options = do pure $ options { optionsIsTerminal = isTerminal , optionsFormatter = if isTerminal then terminalFormatter else logfmtFormatter + , optionsPrintSource = isTerminal , optionsProcessID = pid } diff --git a/src/SemanticCmdLine.hs b/src/SemanticCmdLine.hs index 2b11694a9..ab250b6f7 100644 --- a/src/SemanticCmdLine.hs +++ b/src/SemanticCmdLine.hs @@ -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.")) <*> 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.") - <*> 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")) -- The rest of the logging options are set automatically at runtime. <*> pure False -- IsTerminal + <*> pure False -- PrintSource <*> pure Log.logfmtFormatter -- Formatter <*> pure 0 -- ProcessID argumentsParser = (. Task.writeToOutput) . (>>=)