Legrand / Raritan / Server Technology Xerus™ JSON-RPC API
Loading...
Searching...
No Matches
Log.idl
1
/* SPDX-License-Identifier: BSD-3-Clause */
2
/*
3
* Copyright 2014 Raritan Inc. All rights reserved.
4
*/
5
6
#ifndef __LOG_IDL__
7
#define __LOG_IDL__
8
9
/**
10
* Device Logging
11
*
12
* Log:
13
* - organized as a ring buffer
14
* - divided into multiple log chunks
15
* - size is limited (based on amount of storage and not the message count)
16
* - if size limit is reached then the oldest log messages will be removed (in log chunk granularity)
17
* - real size may vary over time because of optional compression and chunk-wise removal of old messages
18
*
19
* Log chunk:
20
* - contains log messages
21
* - usually represented by a dedicated file in the backend
22
* - size is limited (based on amount of storage and not the message count)
23
* - real size may vary slightly
24
*
25
* Log messages:
26
* - have an associated log message id
27
* - the id is not persistent, i.e. id assignment starts from beginning when
28
* - restarting the log service (e.g. by rebooting the device)
29
* - clearing the log
30
*
31
* Log message id:
32
* - unsigned 32bit integer in the backend
33
* - mapped to a signed 32bit integer in IDL
34
* - when the id reaches 2^31 then the IDL representation of the id will become negative
35
* - at 2^32 the id will wrap to 0
36
* - the id start with 0 and is incremented by 1 with each log message
37
*
38
* Id reset detection:
39
* 1. Retrieve LogInfo via getInfo() and remember the creationTime.
40
* 2. When retrieving log messages via getChunk() compare the logCreationTime with the creationTime from
41
* getInfo().
42
* 3. If they differ then the id numbering has been reset.
43
*
44
* Log message retrieval:
45
* - only chunk-wise (a chunk is usually represented by a file in the backend)
46
* - one chunk at a time
47
* - when requested start id is in the middle of the chunk then entries before this id are not returned
48
* - when more messages are requested than available in a chunk after the start id then only the available
49
* messages are returned
50
* - requesting 2^31-1 (INT32_MAX) or -1 (2^32-1 (UINT32_MAX) casted to a signed 32bit integer) entries
51
* will ensure you get everything in the requested chunk after the start id
52
* - when going forward: if start id is lower than the first id then the start id is set to the first id
53
* - when going backward: if start id is greater than the last id then the start id is set to the last id
54
*
55
* Examples:
56
*
57
* Retrieving whole log forward from the beginning:
58
*
59
* 1. Get current log info by calling getInfo() and remember it.
60
* 2. Set the start id to idFirst from the log info.
61
* 3. Get chunk by calling getChunk(FORWARD) starting at the start id and requesting -1 entries
62
* (see Log message retrieval above for why using -1 here).
63
* 4. Compare chunk's logCreationTime with the creationTime from log info. If different then restart whole
64
* retrieval (log service was restarted or log was cleared).
65
* 5. Process retrieved log messages if any.
66
* 6. If allEntryCnt of the chunk is 0 then stop (the end of the log has been reached).
67
* 7. Calculate next start id by adding idFirst and allEntryCnt of the current chunk and go to step 3.
68
*
69
* Retrieving whole log backward from the end:
70
*
71
* 1. Get current log info by calling getInfo() and remember it.
72
* 2. If idNext in the logInfo is 0 then stop (log is empty).
73
* 3. Set the start id to idNext-1 (i.e. one less then idNext) from the log info.
74
* 4. Get chunk by calling getChunk(BACKWARD) starting at the start id and requesting -1 entries
75
* (see Log message retrieval above for why using -1 here).
76
* 5. Compare chunk's logCreationTime with the creationTime from log info. If different then restart whole
77
* retrieval (log service was restarted or log was cleared).
78
* 6. Process retrieved log messages if any.
79
* 7. If idFirst or allEntryCnt of the chunk is 0 then stop (the start of the log has been reached).
80
* 8. Calculate next start id by subtracting 1 from idFirst of the current chunk and go to step 4.
81
*/
82
module
logging
{
83
84
/** General log info */
85
structure
LogInfo
{
86
long
creationTime
;
///< Creation time of log (monotonic clock timestamp).
87
///< Changed by clear() and service restart/reboot.
88
int
idFirst
;
///< Id of first entry of the log
89
int
idNext
;
///< Next unused entry id of the log
90
};
91
92
/** A log entry */
93
structure
LogEntry
{
94
int
id
;
///< Entry id
95
time
timestamp
;
///< Creation time of this entry (UNIX timestamp, UTC)
96
string
eventClass
;
///< Category (aka event class)
97
string
message
;
///< Log message
98
};
99
100
/** A log chunk */
101
structure
LogChunk
{
102
long
logCreationTime
;
///< Creation time of log at chunk generation (monotonic clock timestamp)
103
int
idFirst
;
///< Id of first entry in the chunk
104
int
allEntryCnt
;
///< Count of all entries in the chunk
105
vector<LogEntry>
selEntries
;
///< Selected entries of the chunk
106
};
107
108
/** Range direction when fetching log entries */
109
enumeration
RangeDirection
{
110
FORWARD
,
///< Fetch log entries with id, id+1, id+2, ...
111
BACKWARD
///< Fetch log entries with id, id-1, id-2, ...
112
};
113
114
}
115
116
#endif
/* __LOG_IDL__ */
logging
Device Logging.
Definition
DebugLog.idl:14
logging::RangeDirection
RangeDirection
Range direction when fetching log entries.
Definition
Log.idl:109
logging::FORWARD
@ FORWARD
Fetch log entries with id, id+1, id+2, ...
Definition
Log.idl:110
logging::BACKWARD
@ BACKWARD
Fetch log entries with id, id-1, id-2, ...
Definition
Log.idl:111
logging::LogChunk
A log chunk.
Definition
Log.idl:101
logging::LogChunk::allEntryCnt
int allEntryCnt
Count of all entries in the chunk.
Definition
Log.idl:104
logging::LogChunk::idFirst
int idFirst
Id of first entry in the chunk.
Definition
Log.idl:103
logging::LogChunk::selEntries
vector< LogEntry > selEntries
Selected entries of the chunk.
Definition
Log.idl:105
logging::LogChunk::logCreationTime
long logCreationTime
Creation time of log at chunk generation (monotonic clock timestamp)
Definition
Log.idl:102
logging::LogEntry
A log entry.
Definition
Log.idl:93
logging::LogEntry::eventClass
string eventClass
Category (aka event class)
Definition
Log.idl:96
logging::LogEntry::message
string message
Log message.
Definition
Log.idl:97
logging::LogEntry::id
int id
Entry id.
Definition
Log.idl:94
logging::LogEntry::timestamp
time timestamp
Creation time of this entry (UNIX timestamp, UTC)
Definition
Log.idl:95
logging::LogInfo
General log info.
Definition
Log.idl:85
logging::LogInfo::idFirst
int idFirst
Id of first entry of the log.
Definition
Log.idl:88
logging::LogInfo::creationTime
long creationTime
Creation time of log (monotonic clock timestamp).
Definition
Log.idl:86
logging::LogInfo::idNext
int idNext
Next unused entry id of the log.
Definition
Log.idl:89
Generated on Thu Jun 18 2026 06:08:00 for Legrand / Raritan / Server Technology Xerus™ JSON-RPC API by
1.13.2