Skip to content

Commit

Permalink
Merge pull request #51 from ralatsdc/rl/pass-logging-level
Browse files Browse the repository at this point in the history
Pass log level
  • Loading branch information
arichadda authored Oct 2, 2023
2 parents 7b297e7 + 32838bf commit 25f4536
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions core/base_mqtt_pub_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import json
from typing import Callable, Any, Dict, List, Union
import paho.mqtt.client as mqtt
import logging
import coloredlogs


Expand All @@ -21,6 +20,7 @@ class BaseMQTTPubSub:
REGISTRATION_TOPIC = "/registration"
HEARTBEAT_TOPIC = "/heartbeat"
HEARTBEAT_FREQUENCY = 10 # seconds
COLORED_LOGS_LEVEL = "INFO"
COLORED_LOGS_STYLES = {
"critical": {"bold": True, "color": "red"},
"debug": {"color": "green"},
Expand All @@ -41,6 +41,7 @@ def __init__(
registration_topic: str = REGISTRATION_TOPIC,
heartbeat_topic: str = HEARTBEAT_TOPIC,
heartbeat_frequency: int = HEARTBEAT_FREQUENCY,
colored_logs_level: str = COLORED_LOGS_LEVEL,
colored_logs_styles: Dict[str, Any] = COLORED_LOGS_STYLES,
) -> None:
"""BaseMQTTPubSub constructor takes constants for the config filepath, heartbeat channel,
Expand All @@ -66,7 +67,7 @@ def __init__(
self.heartbeat_frequency = heartbeat_frequency

coloredlogs.install(
level=logging.INFO,
level=colored_logs_level,
fmt="%(asctime)s.%(msecs)03d \033[0;90m%(levelname)-8s "
""
"\033[0;36m%(filename)-18s%(lineno)3d\033[00m "
Expand Down

0 comments on commit 25f4536

Please sign in to comment.