Uinta v0.4.0 Uinta.Plug View Source
This plug combines the request and response logs into a single line. This brings many benefits including:
Removing the need to visually match up the request and response makes it easier to read your logs and get a full picture of what has happened.
Having a single line for both request and response halves the number of request logs that your log aggregator will need to process and index, which leads to saved costs
In addition to combining the log lines, it also gives you the ability to
output request logs in JSON format so that you can easily have your log
aggregator parse the fields. To do this, pass json: true
in the options
when calling the plug.
Finally, GraphQL requests will replace POST /graphql
with the GraphQL
operation type and name like QUERY getUser
or MUTATION createUser
if an
operation name is provided. This will give you more visibility into your
GraphQL requests without having to log out the entire request body or go
into debug mode. If desired, the GraphQL variables can be included in the
log line as well. The query can also be included if unnamed.
Installation
To install this, find this line (typically in YourApp.Endpoint
):
plug Plug.Logger
and replace it with this (using only the options you want):
plug Uinta.Plug,
log: :info,
json: false,
include_variables: false,
filter_variables: []
Options
:log
- The log level at which this plug should log its request info. Default is:info
:json
- Whether or not this plug should log in JSON format. Default isfalse
:include_variables
- Whether or not to include any GraphQL variables in the log line when applicable. Default isfalse
.:filter_variables
- A list of variable names that should be filtered out from the logs. By defaultpassword
,passwordConfirmation
,idToken
, andrefreshToken
will be filtered.:include_unnamed_queries
- Whether or not to include the full query body for queries with no name supplied
Link to this section Summary
Link to this section Types
opts()
View Sourceopts() :: %{ level: Logger.level(), format: format(), include_unnamed_queries: boolean(), include_variables: boolean(), filter_variables: [String.t()] }