amberframework / amber

A Crystal web framework that makes building applications fast, simple, and enjoyable. Get started with quick prototyping, less bugs, and blazing fast performance.
https://amberframework.org
MIT License
2.57k stars 206 forks source link

Improve default log formatting & output #1238

Closed noahlh closed 3 years ago

noahlh commented 3 years ago

Description of the Change

With the new changes to logging, a default Amber installation produces slightly wonky log output. See below:

Screen Shot 2020-11-10 at 8 58 32 PM

There are two issues here:

  1. Standard log messages are repeated.
  2. Log messages from pipelines have a redundant prog parameter. This is because the new Log implementation now supports sources natively, but the relevant amber code still includes the prog parameter twice.

This PR makes a few small changes to improve things:

  1. The prog parameter is only written once, colorized if necessary
  2. The default formatting of pipeline log lines (with a | character separating the source from the msg) is moved from source code up to the configuration file. This gives the user additional flexibility in customizing how log lines are displayed without mucking around in amber source\
  3. Log.builder.clear is added to the default config/logger.cr in order to resolve the double log lines. There is still a brief double log when amber first fires up before the config file is loaded -- there may be a better way to fix this.

Benefits

Cleaner logs! See below for default output with these changes applied:

Screen Shot 2020-11-10 at 9 13 11 PM

Possible Drawbacks

Slightly more complex & longer configuration for logging (config/logger.cr)