mirror of
https://github.com/github/semantic.git
synced 2024-12-28 09:21:35 +03:00
Merge pull request #277 from github/build-sha-as-config-version
Include real build sha in production logs
This commit is contained in:
commit
247e4bed54
@ -29,6 +29,7 @@ import Semantic.Env
|
||||
import Semantic.Telemetry
|
||||
import qualified Semantic.Telemetry.Error as Error
|
||||
import qualified Semantic.Telemetry.Stat as Stat
|
||||
import Semantic.Version (buildSHA)
|
||||
import System.Environment
|
||||
import System.IO (hIsTerminalDevice, stdout)
|
||||
import System.Posix.Process
|
||||
@ -52,7 +53,7 @@ data Config
|
||||
, configIsTerminal :: Flag IsTerminal -- ^ Whether a terminal is attached (set automaticaly at runtime).
|
||||
, configLogPrintSource :: Flag LogPrintSource -- ^ Whether to print the source reference when logging errors (set automatically at runtime).
|
||||
, configLogFormatter :: LogFormatter -- ^ Log formatter to use (set automatically at runtime).
|
||||
, configSHA :: Maybe String -- ^ Optional SHA to include in log messages.
|
||||
, configSHA :: String -- ^ SHA to include in log messages (set automatically).
|
||||
, configFailParsingForTesting :: Flag FailTestParsing -- ^ Simulate internal parse failure for testing (default: False).
|
||||
, configOptions :: Options -- ^ Options configurable via command line arguments.
|
||||
}
|
||||
@ -97,7 +98,7 @@ defaultConfig options@Options{..} = do
|
||||
, configIsTerminal = flag IsTerminal isTerminal
|
||||
, configLogPrintSource = flag LogPrintSource isTerminal
|
||||
, configLogFormatter = if isTerminal then terminalFormatter else logfmtFormatter
|
||||
, configSHA = Nothing
|
||||
, configSHA = buildSHA
|
||||
, configFailParsingForTesting = flag FailTestParsing False
|
||||
|
||||
, configOptions = options
|
||||
@ -121,7 +122,7 @@ logOptionsFromConfig Config{..} = LogOptions
|
||||
| otherwise = [ ("app", configAppName)
|
||||
, ("pid", show configProcessID)
|
||||
, ("hostname", configHostName)
|
||||
, ("sha", fromMaybe "development" configSHA)
|
||||
, ("sha", configSHA)
|
||||
]
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user