forked from code-corps/code-corps-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtimber.exs
More file actions
61 lines (53 loc) · 1.98 KB
/
timber.exs
File metadata and controls
61 lines (53 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
use Mix.Config
# Update the instrumenters so that we can structure Phoenix logs
config :code_corps, CodeCorpsWeb.Endpoint,
instrumenters: [Timber.Integrations.PhoenixInstrumenter]
# Structure Ecto logs
config :code_corps, CodeCorps.Repo,
loggers: [{Timber.Integrations.EctoLogger, :log, []}]
# Sets the Logger application to use the `:console` backend with UTC-oriented
# timestamps
config :logger,
backends: [:console],
utc_log: true
# Configures the `:console` backend to:
# - Use Timber.Formatter.format/4 to format log lines
# - Pass _all_ metadata for every log line into formatters
config :logger, :console,
format: {Timber.Formatter, :format},
metadata: :all
# Configures the Timber.Formatter to:
# - Colorize the log level
# - Format metadata using logfmt (if metadata printing is enabled)
# - Print the log level
# - Print the timestamp
# Note: print_metadata is false, so the format key will be ignored
config :timber, Timber.Formatter,
colorize: true,
format: :logfmt,
print_log_level: true,
print_metadata: false,
print_timestamps: true
# Compiling the configuration from the following Mix environments will result
# in the Timber.Formatter using a "production friendly" configuration.
environments_to_include = [
:prod,
:staging
]
if Enum.member?(environments_to_include, Mix.env()) do
# Configures the Timber.Formatter for outputting to Heroku Logplex
# - Removes log level colorization (since the colorization codes are not machine-friendly)
# - Formats the data using the JSON formatter
# - Removes the log level (this is in the metadata)
# - Prints the metadata at the end of the line
# - Removes the timestamp (this is in the metadata and Heroku will also add its own)
config :timber, Timber.Formatter,
colorize: false,
format: :json,
print_log_level: false,
print_metadata: true,
print_timestamps: false
end
# Need help?
# Email us: [email protected]
# Or, file an issue: https://github.com/timberio/timber-elixir/issues