API documentation
Lognostic
Lognostic is a logging utility class designed to record, store, and analyze logging data. It captures logging information such as logger names, message sizes, and timestamps, providing functionalities to analyze this data for monitoring and debugging purposes.
Attributes:
| Name | Type | Description |
|---|---|---|
_lock |
Lock
|
A threading lock to ensure thread-safe operations on records. |
_records |
List[Dict[str, Timestamp | str | int]]
|
A list to store logging records. |
Source code in src/lognostic/lognostic.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 117 118 119 120 121 122 | |
__init__()
Initializes the Lognostic class by setting up the threading lock and initializing the list of records.
Source code in src/lognostic/lognostic.py
19 20 21 22 23 24 | |
logging_rate_per_logger(lookback_period=60)
Calculates the logging rate per logger over a specified lookback period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lookback_period |
int
|
The lookback period in seconds. Defaults to 60. |
60
|
Returns:
| Type | Description |
|---|---|
Dict[str, float]
|
Dict[str, float]: A dictionary mapping logger names to their average logging rate (message size per second). |
Source code in src/lognostic/lognostic.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
record(log_record)
Records a new logging event by appending it to the list of records.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
log_record |
LogRecord
|
The log record to be recorded, containing the logger's name, |
required |
Source code in src/lognostic/lognostic.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | |
total_logging_rate(lookback_period=60)
Calculates the total logging rate over a specified lookback period.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lookback_period |
int
|
The lookback period in seconds. Defaults to 60. |
60
|
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The average logging rate (message size per second). |
Source code in src/lognostic/lognostic.py
94 95 96 97 98 99 100 101 102 103 104 105 106 | |
total_size()
Calculates the total size of all logged messages.
Returns:
| Name | Type | Description |
|---|---|---|
int |
int
|
The total size of all messages. |
Source code in src/lognostic/lognostic.py
73 74 75 76 77 78 79 80 81 82 | |
total_size_per_logger()
Calculates the total size of logged messages per logger.
Returns:
| Type | Description |
|---|---|
Dict[str, int]
|
Dict[str, int]: A dictionary mapping logger names to their total message size. |
Source code in src/lognostic/lognostic.py
84 85 86 87 88 89 90 91 92 | |