|
37 | 37 | #include <lib/support/CHIPCounter.h>
|
38 | 38 | #include <messaging/ExchangeMgr.h>
|
39 | 39 |
|
| 40 | +/** |
| 41 | + * Events are stored in the LogStorageResources provided to |
| 42 | + * EventManagement::Init. |
| 43 | + * |
| 44 | + * A newly generated event will be placed in the lowest-priority (in practice |
| 45 | + * DEBUG) buffer, the one associated with the first LogStorageResource. If |
| 46 | + * there is no space in that buffer, space will be created by evicting the |
| 47 | + * oldest event currently in that buffer, until enough space is available. |
| 48 | + * |
| 49 | + * When an event is evicted from a buffer, there are two possibilities: |
| 50 | + * |
| 51 | + * 1) If the next LogStorageResource has a priority that is no higher than the |
| 52 | + * event's priority, the event will be moved to that LogStorageResource's |
| 53 | + * buffer. This may in turn require events to be evicted from that buffer. |
| 54 | + * 2) If the next LogStorageResource has a priority that is higher than the |
| 55 | + * event's priority, then the event is just dropped. |
| 56 | + * |
| 57 | + * This means that LogStorageResources at a given priority level are reserved |
| 58 | + * for events of that priority level or higher priority. |
| 59 | + * |
| 60 | + * As a simple example, assume there are only two priority levels, DEBUG and |
| 61 | + * CRITICAL, and two LogStorageResources with those priorities. In that case, |
| 62 | + * old CRITICAL events will not start getting dropped until both buffers are |
| 63 | + * full, while old DEBUG events will start getting dropped once the DEBUG |
| 64 | + * LogStorageResource buffer is full. |
| 65 | + */ |
| 66 | + |
40 | 67 | #define CHIP_CONFIG_EVENT_GLOBAL_PRIORITY PriorityLevel::Debug
|
41 | 68 |
|
42 | 69 | namespace chip {
|
@@ -162,31 +189,28 @@ struct LogStorageResources
|
162 | 189 |
|
163 | 190 | /**
|
164 | 191 | * @brief
|
165 |
| - * A class for managing the in memory event logs. |
166 |
| - * Assume we have two importance levels. DEBUG and CRITICAL, for simplicity, |
167 |
| - * A new incoming event will always get logged in buffer with debug buffer no matter it is Debug or CRITICAL event. |
168 |
| - * In order for it to get logged, we need to free up space. So we look at the tail of the buffer. |
169 |
| - * If the tail of the buffer contains a DEBUG event, that will be dropped. If the tail of the buffer contains |
170 |
| - * a CRITICAL event, that event will be 'promoted' to the next level of buffers, where it will undergo the same procedure |
171 |
| - * The outcome of this management policy is that the critical buffer is dedicated to the critical events, and the |
172 |
| - * debug buffer is shared between critical and debug events. |
| 192 | + * A class for managing the in memory event logs. See documentation at the |
| 193 | + * top of the file describing the eviction policy for events when there is no |
| 194 | + * more space for new events. |
173 | 195 | */
|
174 | 196 |
|
175 | 197 | class EventManagement
|
176 | 198 | {
|
177 | 199 | public:
|
178 | 200 | /**
|
179 |
| - * @brief |
180 |
| - * Initialize the EventManagement with an array of LogStorageResources. The |
181 |
| - * array must provide a resource for each valid priority level, the elements |
182 |
| - * of the array must be in increasing numerical value of priority (and in |
183 |
| - * increasing priority); the first element in the array corresponds to the |
184 |
| - * resources allocated for least important events, and the last element |
185 |
| - * corresponds to the most critical events. |
| 201 | + * Initialize the EventManagement with an array of LogStorageResources and |
| 202 | + * an equal-length array of CircularEventBuffers that correspond to those |
| 203 | + * LogStorageResources. The array of LogStorageResources must provide a |
| 204 | + * resource for each valid priority level, the elements of the array must be |
| 205 | + * in increasing numerical value of priority (and in increasing priority); |
| 206 | + * the first element in the array corresponds to the resources allocated for |
| 207 | + * least important events, and the last element corresponds to the most |
| 208 | + * critical events. |
186 | 209 | *
|
187 | 210 | * @param[in] apExchangeManager ExchangeManager to be used with this logging subsystem
|
188 | 211 | *
|
189 |
| - * @param[in] aNumBuffers Number of elements in inLogStorageResources array |
| 212 | + * @param[in] aNumBuffers Number of elements in the apLogStorageResources |
| 213 | + * and apCircularEventBuffer arrays. |
190 | 214 | *
|
191 | 215 | * @param[in] apCircularEventBuffer An array of CircularEventBuffer for each priority level.
|
192 | 216 | *
|
|
0 commit comments