tvkitchen / countertop

The entry point for developers who want to set up a TV Kitchen.
https://tv.kitchen
GNU Lesser General Public License v3.0
6 stars 2 forks source link

The default logger should be silent shouldn't it... #101

Closed slifty closed 4 years ago

slifty commented 4 years ago

Task

Description

The default logger writes to console, which is cool and all, except this means that the default behavior is to log everything to console (e.g. including trace).

It would probably be friendly to not do that.

Not going to implement this until after we discuss though, since I don't want to keep painting the logger bike shed for all eternity.

Relevant Resources / Research

Nah

Related Issues

Nope

chriszs commented 4 years ago

Yes, I think that's right for trace and debug at least. Possibly not error. What you might want to do is establish a log level, put it in an environment variable and then mute everything beneath that.

slifty commented 4 years ago

OK, sounds like this would be good:

  1. Have it pick up on an environment variable (I'll see if a standard one exists, e.g. LOG_LEVEL)
  2. If a value does not exist, have it default to silent for debug and trace.
slifty commented 4 years ago

On a related note, I'd like to modify the default logger to never use console.trace <-- that outputs a full stack trace in addition to the message, which is quite noisy!

slifty commented 4 years ago

No standard name seems to exist, so we could either do LOG_LEVEL or we can do something more unique to TVK such as TVK_LOG_LEVEL.

Here's what is tripping me up: a dev can pass their own logger and bypass this. We want the default behavior to be good behavior, but I'm wary of overcomplicating by providing too many ways to customize logging...

Here are some options in front of me:

  1. Have the default logger be COMPLETELY silent at all levels. The developer would have to pass a logger if they want any form of logging.

  2. Have the default logger silence debug and trace, and always output above that. A developer who wants different behavior must pass their own logger to change it.

  3. Have the default logger use an environment variable (e.g. TVK_LOG_LEVEL) with a default value of INFO. The developer could then change log levels without having to pass a custom logger.

  4. None of the above -- don't look at environment variables at all, and instead have a logLevel config value that is passed to the Countertop.

kafkajs uses option 4, and we probably should do that too.

slifty commented 4 years ago

Moving back to 1: default of no logging (silent logger). If an application wants to have logging, they provide a logger that isn't silent, configured to the levels they want.