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

fix(logger): use custom logger #336

Merged
merged 3 commits into from
Mar 18, 2024
Merged

fix(logger): use custom logger #336

merged 3 commits into from
Mar 18, 2024

Conversation

justinmk
Copy link
Member

Problem:

Solution:

  • Update all logging calls to use the custom logger.
  • Skip initialization of winstonLogger if a custom logger is given.

before:

    ● Node host › can run a command from plugin
      failed request to "nvim_command" (see $NVIM_NODE_LOG_FILE for details, if it was set)
        75 |     request(name, args = []) {
        76 |         // Dummy error, to get stacktrace.
      > 77 |         const error = new Error(`failed request to "${name}" (see $NVIM_NODE_LOG_FILE for details, if it was set)`);
           |                       ^
        78 |         return this.asyncRequest(name, args, error.stack);
        79 |     }
        80 |     _getArgsByPrefix(...args) {
        at NeovimClient.request (../neovim/lib/api/Base.js:77:23)
        at NeovimClient.request (../neovim/lib/api/Neovim.js:355:21)
        at Object.command (__tests__/integration.test.ts:85:16)

after:

    ● Node host › can run a command from plugin
      nvim_command: Vim:E492: Not an editor command: JSHostTestCmd
        67 |             return this[DO_REQUEST](name, args).catch(err => {
        68 |                 // XXX: Get a `*.ts stacktrace. If we re-throw `err` we get a `*.js` trace. tsconfig issue?
      > 69 |                 const newError = new Error(err.message);
           |                                  ^
        70 |                 this.logger.error(`failed request to "%s": %s: %s`, name, newError.name, newError.message);
        71 |                 throw newError;
        72 |             });
        at ../neovim/lib/api/Base.js:69:34
        at Object.<anonymous> (__tests__/integration.test.ts:85:5)
Problem:
d9bc2ef #138 allows clients to supply
a custom logger, but the logger is not always used. And the
winstonLogger is always initialized, even when a custom logger is given.

Solution:
- Update all logging calls to use the custom logger.
- Skip initialization of winstonLogger if a custom logger is given.
cli.js is a low-level, minimal entrypoint.
@justinmk justinmk merged commit 899a54f into master Mar 18, 2024
11 checks passed
@justinmk justinmk deleted the logobject branch March 18, 2024 14:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant