forked from osl-incubator/scicookie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogs.py
35 lines (26 loc) · 969 Bytes
/
logs.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
35
"""Module for functions and classes for systen logs."""
import os
from enum import Enum
from colorama import Fore
class SciCookieErrorType(Enum):
"""Enum class for the error codes."""
SH_ERROR_RETURN_CODE = 1
SH_KEYBOARD_INTERRUPT = 2
SCICOOKIE_INVALID_PARAMETER = 3
SCICOOKIE_MISSING_PARAMETER = 4
SCICOOKIE_INVALID_CONFIGURATION = 5
class SciCookieLogs:
"""Main log for print and raise messages to the system."""
@staticmethod
def raise_error(message: str, message_type: SciCookieErrorType):
"""Print an error message and exit with the given error code."""
print(Fore.RED, f"[EE] {message}", Fore.RESET)
os._exit(message_type.value)
@staticmethod
def info(message: str):
"""Print an info message."""
print(Fore.BLUE, message, Fore.RESET)
@staticmethod
def warning(message: str):
"""Print a warning message."""
print(Fore.YELLOW, message, Fore.RESET)