Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is not possible to get the default logger object in Caporal 2 #205

Closed
1 of 2 tasks
jhorbulyk opened this issue Apr 7, 2021 · 1 comment
Closed
1 of 2 tasks

Comments

@jhorbulyk
Copy link
Contributor

Is your feature request related to a problem? Please describe.
Winston, unlike other logging libraries such as bunyan, lacks a .trace() method. This means that if I use a Winston with libraries that expect loggers to have .trace() methods, those libraries will fail. One simple work around is to simply add a .trace() function to the logger object that is equivalent to Winston's .silly() or .debug(). In Caproal, 1.X the entire problem could be resolved by adding the following 3 lines of code to your main entry file:

// Make winston logger bunyan compatible
const logger = program.logger();
logger.trace = logger.debug;

The above code gets the default logger object and then wires in the missing level. Unfortunately, no similar equivalent is possible in Caporal v 2.X as there is only a logger setter with no corresponding getter.

Describe the solution you'd like
Either

  • A: In Caproal v2, running program.logger() should return the current logger used by the program and not set the logger to undefined.
    or
  • B: program has a new property logger which is the logger object used by the program.

Describe alternatives you've considered
Monkey patch the line logger.trace = logger.debug; to the beginning of every action function.

Additional context

Would you be able to work on it and provide a pull request ?

  • Yes
  • No
github-actions bot pushed a commit that referenced this issue Aug 28, 2023
# [3.1.0](v3.0.0...v3.1.0) (2023-08-28)

### Features

* **logger:** new method: program.getLogger() a8b5fb6, closes #205
@github-actions
Copy link

🎉 This issue has been resolved in version 3.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant