Logger#

class defichain.logger.Logger(directory: str = 'logs', log_level: str = 'input', telegram_token: str = '', telegram_chatid: str = '')#

Creates a Logger object, witch can be passed to the Node and the Ocean object.

There are four types of logging:

  1. input: this only logs values that are inserted into a method and errors

  2. output: this only logs values that are outputted by a method and errors

  3. error: this only logs errors.

  4. all: this logs everything

If telegram token and telegram chatid is passed, then the logs are also sent via telegram after the respective log level.

Parameters:
  • directory (str) – (optional) directory where the logs should be stored (default: next to the script in a logs folder)

  • log_level (str) – (optional) input, output, error, all (default: input)

  • telegram_token (str) – (optional) the telegram token

  • telegram_chatid (str) – (optional) the telegram chatid

Example:
>>> from defichain import Ocean
>>> from defichain.logger import Logger  # import Logger
>>>
>>> logger = Logger(log_level="error")  # initialize logger with log level error
>>>
>>> ocean = Ocean(logger=logger)  # pass logger to Ocean instance
>>>
>>> ocean.address.getBalance("wrong_address")  # error will get logged
Error will get logged