MCPcopy Create free account
hub / github.com/PlatformLab/NanoLog / LogMessage

Class LogMessage

runtime/Log.h:700–836  ·  view source on GitHub ↗

* This class embodies a runtime log statement returned from * Decoder::getNextLogStatement(). It stores the static and dynamic * information associated with the log statement. The only information * missing is the type information for the dynamic arguments. Users of this * class must know the dynamic arguments' types to push() and get() them. * * Also, this class stor

Source from the content-addressed store, hash-verified

698 * 16-byte dynamic arguments (i.e. long long double) are not supported.
699 */
700 class LogMessage {
701 PRIVATE:
702 // Starting number of arguments that the base structure can store
703 // without allocating more space.
704 static const int INITIAL_SIZE = 10;
705
706 // Pointer to the log statement's static arguments; a value of
707 // nullptr indicates that this LogMessage's contents are invalid.
708 FormatMetadata *metadata;
709
710 // Identifier for the log statement assigned by the preprocessor.
711 // A value of uint32_t(-1) is invalid.
712 uint32_t logId;
713
714 // Runtime timestamp of the log statement.
715 uint64_t rdtsc;
716
717 // Number of runtime arguments currently stored in the structure
718 int numArgs;
719
720 // Total number of arguments that can be stored in this structure
721 // without additional memory allocation
722 int totalCapacity;
723
724 // Initial container for arguments
725 uint64_t rawArgs[INITIAL_SIZE];
726
727 // Extension for the arguments if we run out of space above
728 uint64_t *rawArgsExtension;
729
730 void reserve(int nparams);
731
732 PUBLIC:
733 explicit LogMessage();
734 ~LogMessage();
735
736 bool valid();
737 int getNumArgs();
738 uint32_t getLogId();
739 uint64_t getTimestamp();
740 void reset(FormatMetadata *fm= nullptr, uint32_t logId=uint32_t(-1),
741 uint64_t rdtsc=0);
742
743 /**
744 * Add a dynamic log argument into the structure.
745 *
746 * Note: only 8-byte arguments are supported; this means that the
747 * "long double" type is not supported.
748 *
749 * \tparam T
750 * Type of the argument to be added to the structure (deduced)
751 * \param in
752 * The argument to add to the structure
753 */
754 template<typename T>
755 inline void
756 push(T in) {
757 if (numArgs == totalCapacity)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected