fullstack-build / tslog

📝 tslog - Universal Logger for TypeScript and JavaScript
https://tslog.js.org
MIT License
1.35k stars 63 forks source link

Feature Request: please bring back log level name constructor where minLevel takes a string #251

Open a-r-d opened 1 year ago

a-r-d commented 1 year ago

Description / Use Case for a Feature

I appears that this is gone from the new code. In the old code you could construct the logger with a string based level instead of a numeric value.

/**
 * All possible log levels
 * @public
 */
export interface ILogLevel {
  0: "silly";
  1: "trace";
  2: "debug";
  3: "info";
  4: "warn";
  5: "error";
  6: "fatal";
}

/**
 * Constructor: logger settings
 * all values are optional and will be pre-filled with default values
 * @public
 */
export interface ISettingsParam {
...

  /** Minimum output log level (e.g. debug), default: "silly" */
  minLevel?: TLogLevelName;

...
}

I believe this is a worse developer experience as a consumer because now in my environment file I can't simply set the log level to be "info" or "debug" or "warn". I have to set it to some ambiguous number.

e.g. - I have to set it to be "3" using the newer constructor. What does "3" mean? Nobody on my team knows unless they look it up in this repo.