Log Module
Logger
Bases: LoggerABC
Class to handle logging functionality.
Source code in devices\raspberry_pi_5\src\log\__init__.py
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|
__init__(writer_messages_queue, tag=None, debug=False, unique_tag=False)
Initialize the Logger class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
writer_messages_queue
|
Queue
|
Queue to hold log messages. |
required |
tag
|
Optional[str]
|
Tag to identify the logger instance. |
None
|
debug
|
Optional[bool]
|
Flag to indicate if the logger is in debug mode. |
False
|
unique_tag
|
Optional[bool]
|
Whether to generate a unique tag for the logger instance. |
False
|
Source code in devices\raspberry_pi_5\src\log\__init__.py
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 |
|
abstracts
LoggerABC
Bases: ABC
Abstract class to handle logging functionality.
Source code in devices\raspberry_pi_5\src\log\abstracts.py
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
|
debug(content)
abstractmethod
Log a debug message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Content of the log message. |
required |
Source code in devices\raspberry_pi_5\src\log\abstracts.py
67 68 69 70 71 72 73 74 75 |
|
error(content)
abstractmethod
Log an error message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Content of the log message. |
required |
Source code in devices\raspberry_pi_5\src\log\abstracts.py
47 48 49 50 51 52 53 54 55 |
|
get_unique_tag(tag)
abstractmethod
Generate a unique tag for the logger instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag
|
str
|
The tag to identify the logger instance. |
required |
Returns:
Name | Type | Description |
---|---|---|
str |
A unique tag for the logger instance. |
Source code in devices\raspberry_pi_5\src\log\abstracts.py
14 15 16 17 18 19 20 21 22 23 24 |
|
info(content)
abstractmethod
Log an informational message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Content of the log message. |
required |
Source code in devices\raspberry_pi_5\src\log\abstracts.py
37 38 39 40 41 42 43 44 45 |
|
log(content, category=Category.INFO)
abstractmethod
Put a log message in the queue.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Content of the log message. |
required |
category
|
Category
|
Category of the log message. |
INFO
|
Source code in devices\raspberry_pi_5\src\log\abstracts.py
26 27 28 29 30 31 32 33 34 35 |
|
warning(content)
abstractmethod
Log a warning message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Content of the log message. |
required |
Source code in devices\raspberry_pi_5\src\log\abstracts.py
57 58 59 60 61 62 63 64 65 |
|
WriterABC
Bases: ABC
Abstract class to handle writing log messages to a file.
Source code in devices\raspberry_pi_5\src\log\abstracts.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
|
run(file_path=Files.get_log_file_path())
abstractmethod
Main loop for the logger to write messages to the log file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
file_path
|
str
|
Path to the log file. |
get_log_file_path()
|
Source code in devices\raspberry_pi_5\src\log\abstracts.py
140 141 142 143 144 145 146 147 148 |
|
decorators
log_on_error()
Decorator to log errors in a method.
Returns:
Name | Type | Description |
---|---|---|
function |
The decorated function that logs errors. |
Source code in devices\raspberry_pi_5\src\log\decorators.py
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 |
|
enums
Category
Bases: Enum
Enum to define the category of log message.
Source code in devices\raspberry_pi_5\src\log\enums.py
4 5 6 7 8 9 10 11 12 13 |
|
message
Message
Class to handle log messages.
Source code in devices\raspberry_pi_5\src\log\message.py
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|
category
property
writable
Get the category of the log message.
Returns:
Name | Type | Description |
---|---|---|
Category |
Category
|
The category of the log message. |
content
property
writable
Get the content of the log message.
Returns:
Name | Type | Description |
---|---|---|
str |
str
|
The content of the log message. |
tag
property
writable
Get the tag of the log message.
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The tag of the log message, or None if not set. |
__init__(content, category=Category.INFO, tag=None)
Initialize the Message class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
content
|
str
|
Content of the log message. |
required |
category
|
Category
|
Category of the log message. |
INFO
|
tag
|
Optional[str]
|
Optional tag for the log message. |
None
|
Source code in devices\raspberry_pi_5\src\log\message.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
|
__repr__()
Representation of the log message.
Returns:
Name | Type | Description |
---|---|---|
str |
The formatted log message. |
Source code in devices\raspberry_pi_5\src\log\message.py
45 46 47 48 49 50 51 52 |
|
__str__()
String representation of the log message.
Returns:
Name | Type | Description |
---|---|---|
str |
The formatted log message. |
Source code in devices\raspberry_pi_5\src\log\message.py
34 35 36 37 38 39 40 41 42 43 |
|
multiprocessing
writer_target(debug, messages_queue, stop_event)
Target function for a multiprocessing process that handles writing log messages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
debug
|
bool
|
Flag to indicate if the writer is in debug mode. |
required |
messages_queue
|
Queue
|
Queue to hold log messages. |
required |
stop_event
|
Event
|
Event to signal when the process should stop. |
required |
Source code in devices\raspberry_pi_5\src\log\multiprocessing.py
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 |
|
protocols
LoggerConsumerProtocol
Bases: Protocol
Protocol for classes that consume a logger instance.
Source code in devices\raspberry_pi_5\src\log\protocols.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
logger
property
Get the logger instance for the consumer.
Returns:
Name | Type | Description |
---|---|---|
Logger |
Logger
|
The logger instance. |
writer
Writer
Bases: WriterABC
Class to handle writing log messages to a file.
Source code in devices\raspberry_pi_5\src\log\writer.py
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 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
__del__()
Destructor to clean up resources when the photographer is no longer needed.
Source code in devices\raspberry_pi_5\src\log\writer.py
145 146 147 148 149 150 151 152 |
|
__init__(debug, messages_queue, stop_event)
Initialize the Logger class.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
debug
|
bool
|
Flag to indicate if the logger is in debug mode. |
required |
messages_queue
|
Queue
|
Queue to hold log messages. |
required |
stop_event
|
Event
|
Event to signal when the logger should stop. |
required |
Source code in devices\raspberry_pi_5\src\log\writer.py
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 47 48 49 50 |
|