Question: Rename Silly to Step via Config?
Is it possible via configuration to rename the "silly" level to "step"?
I'm designing an automation framework that will be using your logging library (great work btw!). I'd like to use the silly level as a way to report manual testing steps. So it would be ideal if the logs reported "step" instead of "silly".
Thank you very much. :) Unfortunately, it is not yet possible to rename log levels, since type definitions were more important when designing this library. Can you provide me some more background on why it is necessary to rename it?
I appreciate the quick response!
It's a somewhat aesthetic request. I'd prefer the domain language for my automation framework to be "take a look at the step logs" vs. "take a look at the silly logs" ;-)
For more context, I'm building an end-to-end test automation framework. When an automated test fails, my team will review the logs. In particular they'll review "step" (silly) logs as a "step by step" guide for reproducing the failure.
Okay, I think I get where you are coming from. So basically what you need is just to replace the printed out word "silly" rather than the method name itself, correct?
That would be a great stop gap solution.
Ideally it would be both the printed word and method name. But I'm sure renaming the method is not acceptable. I don't want to affect your original design nor cause backward compatibility issues.
Is it possible for me to extend the Logger class and provide a "step" method that delegates to the "silly" method? That is if I can also replace the wording...
I understand, thank you for your explanation. Unfortunately, it is going to be a bigger rewrite and therefore I have to postpone this until the next major update. Sorry about that! I hope you are still able to use it this way.
It would be great if there was an option to rewrite/map log levels, like using Syslog levels instead of the defaults provided by tslog (I've seen this implemented in other logger libraries like winston, see https://github.com/winstonjs/winston#logging-levels & https://github.com/winstonjs/winston#using-custom-logging-levels)
V4 beta is out, which is fully sutomizable. You can easyly define as many log levels as you want, by simply extending BaseLogger.
-
either like this: https://github.com/fullstack-build/tslog/blob/v4/tests/Nodejs/8_json_LogObj.test.ts#L14
-
or like this: https://github.com/fullstack-build/tslog/blob/v4/src/index.ts
Give it a go and let me know if that solves your problem. I'll publish the final version as soon as I have gathered enough feedback.
-
npm i tslog@next -
and run it with
node --enable-source-mapsor for TypeScriptnode --enable-source-maps --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm
V4 is released now, so I'm going to close this issue. Feel free to open a new one if V4 didn't solve it for you.
Here are the docs: tslog.js.org