Repository navigation
main, configuration, doc: allow logging formatter to be configured - #293
Conversation
|
Like it. LGTM! |
|
For the JSON formatter, can we initialize like this by default: log.SetFormatter(&log.JSONFormatter{Service: "registry"}) The "Type" field has special functionality in both Logstash and Heka so we may not want to override that by default. Still, we need a unique way of identifying different services. Either by default or provide a way in the config to add additional fields would be very helpful. Thinking it over.. having it be configurable would be ideal so you can set Type, Service or something else without bothering the distribution team again :) Something like: log:
level: info
formatter: json
fields:
type: registry
service: registry
environment: staging |
|
@avinson That is much preferable. |
Signed-off-by: Stephen J Day <[email protected]>
This changeset simply adds hooks into the configuration system to support multiple different kinds of output formats. These formatters are provided by logrus and include options such as "text" and "json". The configuraiton documentation has been updated accordingly. Signed-off-by: Stephen J Day <[email protected]>
|
LGTM I presume we'll be removing the loglevel configuration option sometime before/around the "stable" tag? |
|
@BrianBland That is purely up to you. I can remove it with this PR, if you're okay with it. |
|
Let's keep it around for a bit longer... |
7ec585c to
9fee680
Compare
To allow flexibility in log message context information, this changeset provides the ability to configure static fields that are included in the context. Such fields can be set via configuration or environment variables. Signed-off-by: Stephen J Day <[email protected]>
9fee680 to
ac73963
Compare
|
LGTM |
main, configuration, doc: allow logging formatter to be configured
This changeset simply adds hooks into the configuration system to support multiple different kinds of output formats. These formatters are provided by logrus and include options such as "text" and "json". The configuraiton documentation has been updated accordingly.
The logrus dependency has been updated as an order of maintenance.
The logging system now has a separate configuration section. The default configuration would be as follows:
This configuration would yield the standard text output, as shown below when output to a TTY:
Using the environment variable
REGISTRY_LOG_FORMATTER, we can take a peak at the other output formats. The logrus package defines an alternative, yet simple json version:The standard logstash output is supported, as well:
Formatters can easily be added in future changes.
This PR also has support for static fields in the log lines. Let's say we add this to the configuration:
We now get a contextual key of "environment" and "service" on each log line:
This works with environment variables, as well:
Note that with this change, the "loglevel" option is now deprecated.
Closes #286.