-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathbase_error.py
More file actions
46 lines (42 loc) · 1.43 KB
/
base_error.py
File metadata and controls
46 lines (42 loc) · 1.43 KB
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
36
37
38
39
40
41
42
43
44
45
46
# Import dependencies
import logging
from datetime import datetime
from abc import ABC, abstractmethod
# Abstract error class
class AbstractError(ABC):
def __init__(self):
"""
Sets the logger file, level, and format.
The logging file will contain the logging level, request date, request status, and model response.
"""
self.logger = logging.getLogger('logger')
date = datetime.now().strftime('%Y-%m-%d')
file_path = 'logs/yolov3_inference_engine_' + date + '.log'
self.handler = logging.FileHandler(file_path)
self.handler.setLevel(logging.INFO)
self.handler.setFormatter(logging.Formatter("%(levelname)s;%(asctime)s;%(message)s"))
self.logger.addHandler(self.handler)
@abstractmethod
def info(self, message):
"""
Logs an info message to the logging file.
:param message: Containing the request status and the model response
:return:
"""
pass
@abstractmethod
def warning(self, message):
"""
Logs a warning message to the logging file.
:param message: Containing the request status and the model response
:return:
"""
pass
@abstractmethod
def error(self, message):
"""
Logs an Error message to the logging file.
:param message: Containing the request status and the model response
:return:
"""
pass