Skip to content

Logging

happy-simulator is silent by default. Enable logging explicitly.

Console Logging

import happysimulator

happysimulator.enable_console_logging(level="DEBUG")

File Logging

happysimulator.enable_file_logging("sim.log", max_bytes=10_000_000)
happysimulator.enable_timed_file_logging("sim.log")

JSON Logging

happysimulator.enable_json_logging()           # to console
happysimulator.enable_json_file_logging("sim.json")  # to file

Environment Variables

happysimulator.configure_from_env()
Variable Description
HS_LOGGING Log level (DEBUG, INFO, WARNING, ERROR)
HS_LOG_FILE Log file path
HS_LOG_JSON Set to 1 for JSON format

Module-Level Control

happysimulator.set_module_level("core.simulation", "DEBUG")
happysimulator.set_level("WARNING")

Disabling

happysimulator.disable_logging()

Next Steps