-
Notifications
You must be signed in to change notification settings - Fork 7
/
definitions.py
35 lines (27 loc) · 969 Bytes
/
definitions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) 2016-2024 Association of Universities for Research in Astronomy, Inc. (AURA)
# For license information see LICENSE or https://opensource.org/licenses/BSD-3-Clause
import os
import sys
import logging
from enum import IntEnum
ROOT_DIR = os.path.dirname(os.path.abspath(__file__))
class LoggingLevels(IntEnum):
INFO = logging.INFO
DEBUG = logging.DEBUG
WARNING = logging.WARNING
ERROR = logging.ERROR
CRITICAL = logging.CRITICAL
FATAL = logging.FATAL
OFF = 100
# Default logging from LOG_LEVEL env variable otherwise INFO
try:
LOG_LEVEL = os.environ['LOG_LEVEL'].upper()
DEFAULT_LOGGING_LEVEL = LoggingLevels[LOG_LEVEL]
except KeyError:
DEFAULT_LOGGING_LEVEL = LoggingLevels.INFO
# If LOG_LEVEL is provided in the command line, use that
if len(sys.argv) == 2:
try:
DEFAULT_LOGGING_LEVEL = LoggingLevels[sys.argv[1].upper()]
except KeyError:
print(f"Invalid log level: {sys.argv[1]}")