catalyst
catalyst copied to clipboard
Feature request: disable all logging
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.
Duplicate of #256
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?
Dosent this work?
Actually I just tried this: os.environ['CATALYST_LOG_LEVEL'] = '13'
And it doesn't work.
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
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.
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
- import the relevant hander in your algo file;
- 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.
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 Right. But unless I'm mistaken, this will also absorb all the data you log with your own custom logs.
@STOpandthink did you manage to disable the logs as you wanted?