Skip to content

Bug: loggelf in lib/errors.js is not overridable #768

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

Open
titanism opened this issue Dec 14, 2024 · 7 comments
Open

Bug: loggelf in lib/errors.js is not overridable #768

titanism opened this issue Dec 14, 2024 · 7 comments

Comments

@titanism
Copy link
Contributor

Currently several parts of the codebase have this line:

const errors = require('../../lib/errors.js');

This requires this module: https://github.com/nodemailer/wildduck/blob/master/lib/errors.js

Specifically this code https://github.com/nodemailer/wildduck/blob/7daa0e35d5462c46ff4228638f2e9e5f30ed880d/lib/errors.js#L75-L90

When errors.notifyConnection(this.this, err); is called throughout the codebase, it uses this default loggelf and outputs to console:

module.exports.gelf.handler = gelfconf.enabled
    ? new Gelf(gelfconf.options)
    : {
          emit: (channel, message) => console.error(util.inspect(message, false, 3))
      };

This uses wild-config and it is documented here https://github.com/nodemailer/wildduck/blob/7daa0e35d5462c46ff4228638f2e9e5f30ed880d/docs/in-depth/operating-wildduck.md?plain=1#L5

There's no way to disable this programmatically, as it has to be read from a config file:

https://github.com/nodemailer/wildduck/blob/2019fd9db6bce1c3167f08e363ab4225b8c8a296/config/default.toml#L59-L66

I suppose we can create a config/default.toml file with this override:

[log]
    [log.gelf]
        enabled=false
        hostname=false # defaults to os.hostname()
        component="wildduck"

However I feel like this should be configurable via code options, e.g. when passed logger option or via server.loggelf.

Curious your thoughts, right now this causes unwanted output in the console for those of us using WildDuck components programmatically.

@titanism
Copy link
Contributor Author

Yes this is a bug, because even if logger is disabled, and if gelf is disabled via the example config above, it will still output to console due to this line: https://github.com/nodemailer/wildduck/blob/7daa0e35d5462c46ff4228638f2e9e5f30ed880d/lib/errors.js#L23

@NickOvt
Copy link
Contributor

NickOvt commented Dec 29, 2024

Hello! Sorry, so what do you want to add? A programmatic way to disable console output for errors? Or just to make it configurable programmatically in the code itself? That is, pass some options object in the code itself?

@titanism
Copy link
Contributor Author

Yes a programmatic way to disable console output or pass a custom logger @NickOvt otherwise it's not obvious how to disable this unwanted output.

Copy link
Contributor

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 15 days.

@titanism
Copy link
Contributor Author

bump

Copy link
Contributor

github-actions bot commented Apr 1, 2025

This issue is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 15 days.

@titanism
Copy link
Contributor Author

titanism commented Apr 1, 2025

bump

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

No branches or pull requests

2 participants