Safe Haskell | None |
---|---|
Language | Haskell2010 |
Reporting to a file.
This reporter logs debugging information about completed requests to a file
or stdout
(in that case, pass in `devstdout` as the file to log to).
Every line this reporter logs is a JSON string. This 'structured logging' output is optimized for external logging platforms that display these logs in a pretty UI.
This logger supports sampling of successful requests, to help save money when sending logs to external services.
Synopsis
- report :: Handler -> Text -> TracingSpan -> IO ()
- data Handler
- handler :: Settings -> IO Handler
- cleanup :: Handler -> IO ()
- data Settings
- decoder :: Decoder Settings
- logFile :: Settings -> FilePath
- appName :: Settings -> Text
- appEnvironment :: Settings -> Text
- fractionOfSuccessRequestsLogged :: Settings -> Float
Documentation
report :: Handler -> Text -> TracingSpan -> IO () Source #
Log tracing information for a request to a file. Tracing information contains nested spans but will appear flattend in the log. Each tracing span will appear on its own line in the log, ordered by its start date.
Example usage:
settings <- File.decode handler <- File.handler settings File.report handler "request-id" span
Contextual information this reporter needs to do its work. You can create
one using handler
.
cleanup :: Handler -> IO () Source #
Clean up your handler after you're done with it. Call this before your application shuts down.
Configuration settings for this reporter. A value of this type can be read
from the environment using the decoder
function.
decoder :: Decoder Settings Source #
Read Settings
from environment variables. Default variables will be used
in case no environment variable is set for an option.
logFile :: Settings -> FilePath Source #
The file to log too. On unix systems you can set this to devstdout
in order to log to stdout.
environment variable
- LOG_FILE
default value
- app.log
appName :: Settings -> Text Source #
The name of this application. This will be attached to all logs.
environment variable
- LOG_ROOT_NAMESPACE
default value
- your-application-name-here
appEnvironment :: Settings -> Text Source #
The environment this application is running in. This will be attached to all logs.
environment variable
- ENVIRONMENT
default value
- development
fractionOfSuccessRequestsLogged :: Settings -> Float Source #
The fraction of requests that should be logged. Set to 1 if you want to log everything, and a lower value to save money.
environment variable
- FRACTION_OF_SUCCESS_REQUESTS_LOGGED
default value
- 1