catalyst icon indicating copy to clipboard operation
catalyst copied to clipboard

Feature request: disable all logging

Open STOpandthink opened this issue 7 years ago • 10 comments

I'd like to disable all logging from Enigma Catalyst. I'm running it in the paper trading mode, but using my own trading API, so I don't need it to print out the balance every minute.

STOpandthink avatar Jul 12 '18 17:07 STOpandthink

Duplicate of #256

AvishaiW avatar Jul 12 '18 19:07 AvishaiW

I'm running multiple instances of Catalyst on one machine. Some of them should have logging enabled. Can we have it per process instead of using an env variable?

STOpandthink avatar Jul 12 '18 19:07 STOpandthink

Dosent this work?

AvishaiW avatar Jul 12 '18 19:07 AvishaiW

Actually I just tried this: os.environ['CATALYST_LOG_LEVEL'] = '13' And it doesn't work.

STOpandthink avatar Jul 13 '18 01:07 STOpandthink

You can load the relevant logger object in your algorithm (initialize function) and attach to it a NullHandler(). Its output will be muted. By modifying the handlers you can tune exactly what you want to see / log to files / and so on... Check the doc here: http://logbook.readthedocs.io/en/latest/ See also: https://discordapp.com/channels/360051864110235648/360084631652925441/463785349651365899

sam31415 avatar Jul 13 '18 10:07 sam31415

This is what I tried:

logger = Logger(ALGO_NAMESPACE)
logger.disable()

But that doesn't work. ALGO_NAMESPACE is the same var I pass to Catalyst.

STOpandthink avatar Jul 13 '18 15:07 STOpandthink

This won't work because you're creating a new logger, leaving the existing ones unchanged. Try to add this to initialize:

from catalyst.exchange.exchange_algorithm import log as log_exchange_algo
from logbook import NullHandler
log_exchange_algo.handlers.append(NullHandler())

Not also that there are several loggers (Their name appear each time they log something.) So you may want to repeat the code above for each of the handlers you want to disable. The logic is

  1. import the relevant hander in your algo file;
  2. modify it in the initialize function as suits you.

By adding other handlers, you can also divert the logs to some other location than the standard output.

sam31415 avatar Jul 13 '18 16:07 sam31415

Thanks, @sam31415! from what I know, you can add it using push_application() as well: from logbook import NullHandler NullHandler().push_application which uses the null_handler from that stage onwards. check the docs

AvishaiW avatar Jul 15 '18 09:07 AvishaiW

@AvishaiW Right. But unless I'm mistaken, this will also absorb all the data you log with your own custom logs.

sam31415 avatar Jul 15 '18 10:07 sam31415

@STOpandthink did you manage to disable the logs as you wanted?

AvishaiW avatar Jul 19 '18 09:07 AvishaiW