How to integrate logging with ezplog¶
Configure one logging policy for applications using ezqt_app.
🔧 Prerequisites¶
- Python 3.11+
- ezqt-app and ezplog installed
- A single application entrypoint where logging is configured once
📝 Steps¶
- Keep library logging passive in ezqt_app.
ezqt_app emits logs with ezplog.lib_mode.get_logger(...) and keeps its own internal printer.
Do not instantiate Ezpl() inside library code.
- Initialize Ezpl once in the host application (recommended).
from ezplog import Ezpl
ezpl = Ezpl(
log_file="app.log",
log_level="INFO",
hook_logger=True,
hook_printer=False,
)
hook_logger=True captures logs emitted by ezqt_app loggers.
hook_printer=False keeps ezqt_app printer behavior unchanged.
- Optionally scope compatibility hooks to selected logger namespaces.
- Run ezqt_app normally.
from ezqt_app import EzApplication, EzQt_App, init
import sys
app = EzApplication(sys.argv)
init()
window = EzQt_App().build()
window.show()
sys.exit(app.exec())
⚙️ Variations¶
Use classic logging code with ezpl compatibility hook¶
If your application already uses logging.getLogger(...), you can keep that code and still route records through ezpl.
import logging
from ezplog import Ezpl, InterceptHandler
Ezpl(log_file="app.log", hook_logger=False, hook_printer=False)
logging.basicConfig(handlers=[InterceptHandler()], level=logging.INFO, force=True)
log = logging.getLogger("my_app")
log.info("Classic logging is now routed through ezpl")
Keep ezqt_app internal debug printer disabled¶
app.config.yaml controls internal debug console output independently from logger hooks:
With debug_printer: false, debug-level printer messages are not displayed.
✅ Result¶
- ezqt_app logs are captured by the host logging policy.
- Library code stays passive and side-effect free.
- Internal ezqt_app printer remains controlled by
app.debug_printer.
🔗 References¶
- Official ezplog guide: How to configure compatibility hooks
- ezplog concept: App mode vs lib mode
- ezqt_app CLI reference: CLI reference