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

Logging level is not configurable #41

Open
weiser opened this issue Nov 7, 2018 · 5 comments
Open

Logging level is not configurable #41

weiser opened this issue Nov 7, 2018 · 5 comments

Comments

@weiser
Copy link
Contributor

weiser commented Nov 7, 2018

I am unable to configure the level at which I want QlessClient to log messages.

Given the following configuration of a worker:

const QLESS_CONFIG = {
  clientConfig: { url: process.env.REDIS_URL },
  interval: 60 * 1000,
  logLevel: 'debug', // 
  queueNames: ['q1', 'q2'],
};

const worker = new qless.workers.Multi(QLESS_CONFIG);
worker.run();

I'd expect to see qless' internal logger to print all debug statements.

However, it appears that the logger is hardcoded to only print warn or higher

I'm happy to make a PR to address this.

@weiser weiser changed the title Logging level is bot configurable Logging level is not configurable Nov 7, 2018
@dlecocq
Copy link

dlecocq commented Nov 7, 2018

Does this approach not work?

qless.logger.level = 'debug';

@weiser
Copy link
Contributor Author

weiser commented Nov 7, 2018

Thanks for pointing that out. FWIW, the context of this is running a qless worker within an integration test.

I think my source of confusion is that I'd expect to be able to pass the logging level to the worker, like:

const QLESS_CONFIG = {
  clientConfig: { url: process.env.REDIS_URL },
  interval: 60 * 1000,
  logLevel: 'debug', // 
  queueNames: ['q1', 'q2'],
};

const worker = new qless.workers.Multi(QLESS_CONFIG); //the worker logs all things above `debug`, since that is what `logLevel` is.
worker.run();

and that logLevel would determine what level the logger logs. Whereas it seems that the logger is configured separately from the worker.

So, it is a bit of a surprise, but running:

...
qless.logger.level = 'debug'
const worker = new qless.workers.Multi(QLESS_CONFIG);
...

does the needful.

I'm not sure if it worth it to keep this issue open. On one hand, if folk are using qless inside integration tests and they want qless to be loud (in our case, travis builds fail infrequently with a QlessClient {} error) it'd be good to know about this.

However, if the main use case is to run a worker through one of the ./bin/*.js scripts, it doesn't seem super helpful to keep this issue open.

Thoughts?

@dlecocq
Copy link

dlecocq commented Nov 7, 2018

Yeah, I was wondering how you were invoking it, but that seems like a legitimate use case.

I'd be open to a PR for this, but I don't see it as the most pressing thing in the world. I think the reason it's not part of the worker creation config is because it's not the case that each worker has a logger - it's global to the library.

@weiser
Copy link
Contributor Author

weiser commented Nov 7, 2018

I think the reason it's not part of the worker creation config is because it's not the case that each worker has a logger - it's global to the library.

Yeah, that's reasonable.

What if I made a PR against the docs that shows how to create a worker, and configure the log level of qless, that could be used in, for example, testing frameworks?

@dlecocq
Copy link

dlecocq commented Nov 7, 2018

Sounds great! Sorry you had to dig around and ultimately open an issue to get it sorted :-/

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