generated from bit-bots/bitbots_template_repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
94 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"cSpell.words": [ | ||
"ddlitlab" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# DDLitLab2024 Project Hamburg Bit-Bots |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import importlib.metadata | ||
import os | ||
import sys | ||
from uuid import UUID, uuid4 | ||
|
||
_project_name: str = "ddlitlab2024" | ||
__version__: str = importlib.metadata.version(_project_name) | ||
|
||
# Craft LOGGING PATH | ||
# Get the log directory from the environment variable or use the default | ||
_logging_dir: str = os.environ.get("DDLITLAB_LOG_DIR", "../logs") | ||
|
||
# Verify that the log directory exists and create it if it doesn't | ||
if not os.path.exists(_logging_dir): | ||
try: | ||
os.makedirs(_logging_dir) | ||
except OSError: | ||
print(f"ERROR: Failed to create log directory {_logging_dir}. Exiting.") | ||
sys.exit(1) | ||
|
||
_logging_path: str = os.path.join(_logging_dir, f"{_project_name}.log") | ||
|
||
# Create log file if it doesn't exist or verify that it is writable | ||
try: | ||
with open(_logging_path, "a"): | ||
pass | ||
except OSError: | ||
print(f"ERROR: Failed to create or open log file {_logging_path}. Exiting.") | ||
sys.exit(1) | ||
|
||
LOGGING_PATH: str = _logging_path | ||
|
||
SESSION_ID: UUID = uuid4() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
import os | ||
|
||
from ddlitlab2024 import LOGGING_PATH, SESSION_ID | ||
|
||
# Init logging | ||
logging.basicConfig( | ||
filename=LOGGING_PATH, | ||
encoding="utf-8", | ||
level=logging.DEBUG, | ||
format=f"%(asctime)s | {SESSION_ID} | %(name)s:%(levelname)s: %(message)s", | ||
) | ||
|
||
# Create additional logging config for the shell with configurable log level | ||
console = logging.StreamHandler() | ||
console.setLevel(os.environ.get("LOGLEVEL", "INFO")) | ||
console.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) | ||
|
||
logger = logging.getLogger("dataset") | ||
logger.addHandler(console) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import logging | ||
import os | ||
|
||
from ddlitlab2024 import LOGGING_PATH, SESSION_ID | ||
|
||
# Init logging | ||
logging.basicConfig( | ||
filename=LOGGING_PATH, | ||
encoding="utf-8", | ||
level=logging.DEBUG, | ||
format=f"%(asctime)s | {SESSION_ID} | %(name)s:%(levelname)s: %(message)s", | ||
) | ||
|
||
# Create additional logging config for the shell with configurable log level | ||
console = logging.StreamHandler() | ||
console.setLevel(os.environ.get("LOGLEVEL", "INFO")) | ||
console.setFormatter(logging.Formatter("%(levelname)s: %(message)s")) | ||
|
||
logger = logging.getLogger("ml") | ||
logger.addHandler(console) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters