-
Notifications
You must be signed in to change notification settings - Fork 0
Usage
Lasse27 edited this page Mar 10, 2025
·
2 revisions
- Configurable Log Levels: Supports DEBUG, INFO, WARNING, and CRITICAL levels.
- Dynamic Scopes: Easily set and clear logging contexts for more granular control.
- Flexible Formatting: Customize log output with template-based, token-driven formatting.
- Dual Logging Outputs: Log messages can be sent to both the console and files (append mode).
- High Throughput: Capable of handling approximately 3000 log messages per second.
Prints the standard format to the console, doesn't print to file and uses the standard time formatting.
The message at level DEBUG is not printed out, since the minimum level is INFO by default:
from fusion_logger_python import *
if __name__ == "__main__":
# Build and configure the logger
logger: FusionLogger = FusionLoggerBuilder().build()
# Log messages at different levels
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warning("This is a warning message.")
logger.critical("This is a critical error message.")Output:
[INFO] 2025-03-10 12:47:02 [FusionLogger] This is an info message.
[WARN] 2025-03-10 12:47:02 [FusionLogger] This is a warning message.
[CRIT] 2025-03-10 12:47:02 [FusionLogger] This is a critical error message.Prints with the specified format to the console. Minimum level is DEBUG, therefore all messages get displayed. Since name isn't specified in the logformat, it is ignored in the output.
if __name__ == "__main__":
# Build and configure the logger
formatter: FusionLogFormatter = FusionLogFormatter("[{LEVEL}] {TIMESTAMP} | {HOSTNAME} {SCOPE} | {MESSAGE}")
logger: FusionLogger = FusionLoggerBuilder() \
.set_formatter(formatter) \
.set_name("SampleLogger") \
.set_min_level(FusionLogLevel.DEBUG) \
.build()
# Log messages at different levels
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.begin_scope("SampleScope")
logger.debug("This is a debug message.")
logger.info("This is an info message.")
logger.warning("This is a warning message.")
logger.critical("This is a critical error message.")
logger.end_scope("SampleScope")
logger.debug("This is a debug message.")
logger.info("This is an info message.")Output
[DEBU] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX | This is a debug message.
[INFO] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX | This is an info message.
[DEBU] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX SampleScope | This is a debug message.
[INFO] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX SampleScope | This is an info message.
[WARN] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX SampleScope | This is a warning message.
[CRIT] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX SampleScope | This is a critical error message.
[DEBU] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX | This is a debug message.
[INFO] 2025-03-10 12:52:45 | DESKTOP-XXXXXXX | This is an info message.FusionLogger-Python Wiki
© 2025 Licensed under the MIT License Organization Repository
• For support or contributions, please open an issue.