habitat.utils.startup¶
Useful functions for daemon startup
Functions
load_config() | Loads the habitat config. |
main(main_class) | Main function for habitat daemons. |
setup_logging(config, daemon_name) | setup_logging initalises the Python logging module. |
Classes
null_logger([level]) | A python logging handler that discards log messages silently. |
- habitat.utils.startup.load_config()[source]¶
Loads the habitat config.
The path to the configuration YAML file can be specified as the single command line argument (read from sys.argv[1]) or will default to ./habitat.yml.
- class habitat.utils.startup.null_logger(level=0)[source]¶
A python logging handler that discards log messages silently.
Initializes the instance - basically setting the formatter to None and the filter list to empty.
- habitat.utils.startup.setup_logging(config, daemon_name)[source]¶
setup_logging initalises the Python logging module.
It will initalise the ‘habitat’ logger and creates one, two, or no Handlers, depending on the values provided for log_file_level and log_stderr_level in config.
- habitat.utils.startup.main(main_class)[source]¶
Main function for habitat daemons. Loads config, sets up logging, and runs.
main_class.__name__.lower() will be used as the config sub section and passed as daemon_name.
main_class specifies a class from which an object will be created. It will be initialised with arguments (config, daemon_name) and then the method run() of the object will be invoked.