CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::LogEntry Struct Reference

Wire/storage layout of one log record: fixed header immediately followed by the message text. More...

#include <Utils.h>

Public Member Functions

const char * getText (uint32 &len)
 Access the text payload stored after the header.
bool setText (char *text, uint32 len)
 Copy len bytes of text into the payload area and update size.
std::string toJSON ()
 Serialize the entry (header fields + text) as a JSON object string.
std::string toXML ()
 Serialize the entry as an XML fragment.

Public Attributes

uint32 size
uint32 cid
uint64 time
uint32 source
uint8 subject
uint8 level
uint8 type

Detailed Description

Wire/storage layout of one log record: fixed header immediately followed by the message text.

The struct is a variable-length blob: size covers the header plus the text payload placed directly after the struct in memory, which makes entries trivially copyable across shared memory and sockets.

Definition at line 228 of file Utils.h.

Member Function Documentation

◆ getText()

const char * cmlabs::LogEntry::getText ( uint32 & len)

Access the text payload stored after the header.

Parameters
[out]lenReceives the payload length in bytes.
Returns
Pointer into this entry's trailing text (not separately allocated).

Definition at line 240 of file Utils.cpp.

References size.

Referenced by toJSON(), and toXML().

◆ setText()

bool cmlabs::LogEntry::setText ( char * text,
uint32 len )

Copy len bytes of text into the payload area and update size.

Parameters
textSource text (need not be NUL-terminated).
lenNumber of bytes to copy.
Returns
true on success.
Note
The caller must have allocated the entry large enough.

Definition at line 247 of file Utils.cpp.

References size.

Referenced by cmlabs::PsyAPI::logPrint(), cmlabs::LogSystem::LogSystemDebug(), and cmlabs::LogSystem::LogSystemPrint().

◆ toJSON()

std::string cmlabs::LogEntry::toJSON ( )

Serialize the entry (header fields + text) as a JSON object string.

Returns
JSON text.

Definition at line 258 of file Utils.cpp.

References cmlabs::utils::EncodeJSON(), getText(), level, source, cmlabs::utils::StringFormat(), subject, time, and type.

◆ toXML()

std::string cmlabs::LogEntry::toXML ( )

Serialize the entry as an XML fragment.

Returns
XML text.

Definition at line 266 of file Utils.cpp.

References cmlabs::html::EncodeHTML(), getText(), level, source, cmlabs::utils::StringFormat(), subject, time, and type.

Member Data Documentation

◆ cid

uint32 cmlabs::LogEntry::cid

◆ level

uint8 cmlabs::LogEntry::level

◆ size

◆ source

uint32 cmlabs::LogEntry::source

◆ subject

uint8 cmlabs::LogEntry::subject

◆ time

uint64 cmlabs::LogEntry::time

◆ type

uint8 cmlabs::LogEntry::type

The documentation for this struct was generated from the following files:
  • /home/ubuntu/c/partner/psyclone2/CMSDK/include/Utils.h
  • /home/ubuntu/c/partner/psyclone2/CMSDK/src/Utils.cpp