tslog icon indicating copy to clipboard operation
tslog copied to clipboard

Question: Rename Silly to Step via Config?

Open nderevjanik-skillz opened this issue 5 years ago • 6 comments

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".

nderevjanik-skillz avatar Dec 23 '20 22:12 nderevjanik-skillz

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?

terehov avatar Dec 23 '20 22:12 terehov

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.

nderevjanik-skillz avatar Dec 23 '20 23:12 nderevjanik-skillz

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?

terehov avatar Dec 23 '20 23:12 terehov

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...

nderevjanik-skillz avatar Dec 23 '20 23:12 nderevjanik-skillz

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.

terehov avatar Dec 24 '20 14:12 terehov

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)

ejose19 avatar Jul 02 '21 18:07 ejose19

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-maps or for TypeScript node --enable-source-maps --experimental-specifier-resolution=node --no-warnings --loader ts-node/esm

terehov avatar Sep 30 '22 14:09 terehov

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

terehov avatar Nov 15 '22 18:11 terehov