Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions slo_generator/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
COLORED_OUTPUT: int = int(os.environ.get("COLORED_OUTPUT", "0"))
DRY_RUN: bool = bool(int(os.environ.get("DRY_RUN", "0")))
DEBUG: int = int(os.environ.get("DEBUG", "0"))
LOGGING_TIMESTAMP_ENABLED: int = int(os.environ.get("LOGGING_TIMESTAMP_ENABLED", "0"))

# Exporters supporting v2 SLO report format
V2_EXPORTERS: Tuple[str, ...] = ("Pubsub", "Cloudevent")
Expand Down
8 changes: 6 additions & 2 deletions slo_generator/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
import yaml
from dateutil import tz

from slo_generator.constants import DEBUG
from slo_generator.constants import DEBUG, LOGGING_TIMESTAMP_ENABLED

try:
# pytype: disable=import-error
Expand Down Expand Up @@ -181,8 +181,12 @@ def setup_logging():
else:
level = logging.INFO
format_str = "%(levelname)s - %(message)s"

if LOGGING_TIMESTAMP_ENABLED == "1":
format_str = "%(asctime)s " + format_str

logging.basicConfig(
stream=sys.stdout, level=level, format=format_str, datefmt="%m/%d/%Y %I:%M:%S"
stream=sys.stdout, level=level, format=format_str, datefmt="%m/%d/%Y %H:%M:%S"
)
logging.getLogger("googleapiclient").setLevel(logging.ERROR)

Expand Down