FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
read_binary_log.hpp
Go to the documentation of this file.
1 #ifndef _READ_BINARY_LOG_HPP_
2 #define _READ_BINARY_LOG_HPP_ "$Id: read_binary_log.hpp 428 2020-07-17 17:16:27Z geoff $"
4 
6 #include <utils/io/read_file.hpp>
8 
20 #pragma GCC diagnostic push
21 #pragma GCC diagnostic ignored "-Wsuggest-final-types"
23 protected:
26  uint32_t parseState;
28  uint32_t parseOffset;
29  uint32_t fileNameLen;
30  uint32_t formatStringLen;
32  const char *fileName;
33  const char *formatString;
38 
39  // It is possible to override this...but you'd really need to want
40  // to do something extremely special...
41  virtual int outputAssembledLine();
42 public:
44  {
46  outputToFD = outputTo;
48  parseOffset = 0;
49  timePointCache = 0;
50  }
51 
53  delete timePointCache;
54  }
55 
57  OS_HANDLE_TYPE result = outputToFD;
58  outputToFD = newFD;
59  return (result);
60  }
61 
62  virtual int processBuffer(File_Buffer *bfrState) VIRTUAL_OVERRIDE;
63 
65  virtual int processLine(const unsigned char *line, size_t lineLen) VIRTUAL_OVERRIDE;
66 
67 }; // end class ReadBinaryLog
68 
69 
74 protected:
78  uint32_t usedByteCount;
79  uint32_t _pad;
80 
82 public:
83  ReadMappedCircularBuffer(const char *fileName);
84 
85  ReadMappedCircularBuffer(size_t regionLen, unsigned char *region);
86 
88 
89  virtual int processBufferContents();
90 
91  virtual int processRegionHeader(const SharedBufferRegionHeader *hdr, size_t segmentLen);
92 
93  virtual int processEndOfBuffer();
94 
95  virtual int processBlock(const SharedBufferAllocRecord *record);
96 
97  virtual int processRecord(const unsigned char *data, size_t recLen);
98 
99 }; // end class ReadMappedCircularBuffer
100 
101 #pragma GCC diagnostic pop
102 
104 #endif
105 /* vim: set expandtab shiftwidth=4 tabstop=4: */
LogLineBinaryHeader::logPrefixMask
unsigned char logPrefixMask
Definition: logging_api.hpp:167
TimePointOfGranularity::OUTPUT_DATE
@ OUTPUT_DATE
Definition: time_point.hpp:599
ReadBinaryLog::formatStringLen
uint32_t formatStringLen
Definition: read_binary_log.hpp:30
LogLineBinaryValueHeader
Header record for a binary output log line.
Definition: logging_api.hpp:134
LogMessageRecord::LOG_ERROR_LEVEL
@ LOG_ERROR_LEVEL
Include level indicator (INFO, ERROR, etc.)
Definition: logging_api.hpp:1042
ReadBinaryLog
Reads a binary log, expands and formats as original plain text. If provided a text file,...
Definition: read_binary_log.hpp:22
read_file.hpp
FARGOS file processing infrastructure.
ReadBinaryLog::outputAssembledLine
virtual int outputAssembledLine()
Process a binary log message buffer and convert to a formatted log line, then invoke processLine() to...
Definition: read_binary_log.cpp:21
ReadBinaryLog::lineHeader
LogLineBinaryHeader * lineHeader
Definition: read_binary_log.hpp:35
ReadBinaryLog::WANT_ARG_VALUE
@ WANT_ARG_VALUE
Definition: read_binary_log.hpp:25
SharedBufferAllocRecord_32
Allocation record for chains in a 32-bit shared memory buffer.
Definition: circular_bfr.hpp:103
BufferRegion::blockAddress
virtual unsigned char * blockAddress(const SharedBufferAllocRecord *record)
Definition: circular_bfr.hpp:282
ReadBinaryLog::WANT_LINE_END
@ WANT_LINE_END
Definition: read_binary_log.hpp:25
ReadBinaryLog::processedArgCount
uint32_t processedArgCount
Definition: read_binary_log.hpp:27
BufferRegion::getActiveListHead
virtual SharedBufferAllocRecord * getActiveListHead()
Return first active allocation record.
Definition: circular_bfr.cpp:196
TimePointOfGranularity::formatIntoString
char * formatIntoString(char *bfr, uint_fast8_t bfrLen, uint_fast8_t *resultLen=nullptr, uint_fast8_t fieldsWanted=OUTPUT_DATE|OUTPUT_TIME, const char *fieldSeparators="/:. ") const
Format into text string.
Definition: time_point.hpp:1273
ReadBinaryLog::argData
const unsigned char * argData[LogMessageRecord::LOG_MAX_ARGUMENT_TOTAL]
Definition: read_binary_log.hpp:37
LogLineBinaryHeader::importanceLevel
uint32_t importanceLevel
Definition: logging_api.hpp:174
byteAsLowercaseHexadecimal
const char byteAsLowercaseHexadecimal[256][3]
Table of uppercase hexadecimal characters for each byte value.
Definition: text2int.cpp:38
LogLineBinaryHeader::offsetFirstArg
uint32_t offsetFirstArg
Definition: logging_api.hpp:180
ReadBinaryLog::ReadBinaryLog
ReadBinaryLog(OS_HANDLE_TYPE fd, OS_HANDLE_TYPE outputTo=_STDOUT_FD)
Definition: read_binary_log.hpp:43
ReadMappedCircularBuffer::processedByteCount
uint32_t processedByteCount
Definition: read_binary_log.hpp:77
LogMessageRecord::getSeverityLabel
static const char * getSeverityLabel(uint_fast32_t level)
Definition: logging_api.cpp:432
File_Buffer
Implements an adjustable sliding buffer that minimizes data movement while enabling streams to proces...
Definition: read_file.hpp:38
TimePointCache
Cache locale-specific time data around a particular point in time.
Definition: time_point.hpp:92
TimePointOfGranularity::OUTPUT_TIME
@ OUTPUT_TIME
Definition: time_point.hpp:600
ReadBinaryLog::parseState
uint32_t parseState
Definition: read_binary_log.hpp:26
ReadMappedCircularBuffer::usedByteCount
uint32_t usedByteCount
Definition: read_binary_log.hpp:78
VIRTUAL_OVERRIDE
#define VIRTUAL_OVERRIDE
Generates override if the compiler supports it.
Definition: compiler_hints.h:435
ReadMappedCircularBuffer::traverseBlockChain
int traverseBlockChain(const SharedBufferAllocRecord *start)
Definition: read_binary_log.cpp:483
BufferRegion::getBufferBase
unsigned char * getBufferBase() const OME_ALWAYS_INLINE
Return the address of the buffer region.
Definition: circular_bfr.hpp:253
ReadBinaryLog::outputToFD
OS_HANDLE_TYPE outputToFD
Definition: read_binary_log.hpp:31
ReadMappedCircularBuffer::bfrMgr
CircularBufferManager * bfrMgr
Definition: read_binary_log.hpp:75
LogLineBinaryHeader::lineNumber
uint32_t lineNumber
Definition: logging_api.hpp:173
ReadBinaryLog::processLine
virtual int processLine(const unsigned char *line, size_t lineLen) VIRTUAL_OVERRIDE
Writes data to output descriptor.
Definition: read_binary_log.cpp:258
ReadMappedCircularBuffer
Interface and generic implementation to traverse elements in a memory-mapped region under the control...
Definition: read_binary_log.hpp:73
BufferRegion::getRegionLength
size_t getRegionLength() const OME_ALWAYS_INLINE
Return the number of bytes in the region.
Definition: circular_bfr.hpp:243
ReadMappedCircularBuffer::processBufferContents
virtual int processBufferContents()
Definition: read_binary_log.cpp:499
BufferRegion::traverseNextBlock
virtual SharedBufferAllocRecord * traverseNextBlock(SharedBufferAllocRecord *record)
Traverse to next allocation record on current chain.
Definition: circular_bfr.cpp:233
LogMessageRecord::LOG_FILENAME
@ LOG_FILENAME
Include source filename on logline.
Definition: logging_api.hpp:1040
LogMessageRecord::LOG_ARG_TYPE_INT64
@ LOG_ARG_TYPE_INT64
Definition: logging_api.hpp:1098
MAP_FILE_READONLY
#define MAP_FILE_READONLY
Definition: mapped_file.h:66
ReadMappedCircularBuffer::~ReadMappedCircularBuffer
~ReadMappedCircularBuffer()
Definition: read_binary_log.cpp:449
LogLineBinaryHeader::threadId
uint64_t threadId
Definition: logging_api.hpp:171
OME_PREFETCH
#define OME_PREFETCH(addr, rw, locality)
Macro to request prefetch.
Definition: compiler_hints.h:362
POSIXtimeInUnits::getSeconds
time_t getSeconds() const OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Convert a POSIXtimeInUnits to seconds since the POSIX epoch.
Definition: time_point.hpp:489
SharedBufferRegionHeader_32
Region header for a 32-bit shared memory segment.
Definition: circular_bfr.hpp:43
ReadBinaryLog::WANT_FILENAME
@ WANT_FILENAME
Definition: read_binary_log.hpp:24
File_Buffer::adjustBufferStart
void adjustBufferStart(size_t amount) OME_ALWAYS_INLINE
Adjusts the start of the active content in the buffer.
Definition: read_file.hpp:163
fixedpoint_to_ascii
char * fixedpoint_to_ascii(char *resultBfr, uint_fast8_t bfrLen, int64_t value, uint_fast8_t precision, uint_fast8_t *retStrLen, int_fast8_t outputPrecision)
Format a fixed-point value with indicated decimal places.
Definition: text2int.cpp:2734
ReadMappedCircularBuffer::processedBlockCount
uint32_t processedBlockCount
Definition: read_binary_log.hpp:76
srcID
const char srcID[]
Definition: catSym.c:17
LOGFILE_BFR_MAGIC_NUMBER
#define LOGFILE_BFR_MAGIC_NUMBER
Magic number for shared memory log file buffer.
Definition: logging_api.hpp:103
LogLineBinaryValueHeader::offsetNextArg
uint32_t offsetNextArg
offset to the next argument
Definition: logging_api.hpp:138
MAX_LINE_LEN
#define MAX_LINE_LEN
Definition: catSym.c:15
LogLineBinaryHeader
Header for encoded log line template and arguments.
Definition: logging_api.hpp:161
LogMessageRecord::LOG_MAX_ARGUMENT_TOTAL
@ LOG_MAX_ARGUMENT_TOTAL
Maximum number of arguments for an output line.
Definition: logging_api.hpp:1030
LogLineBinaryValue
Represents a single binary log element.
Definition: logging_api.hpp:145
LogMessageRecord::LOG_LINE_NUMBER
@ LOG_LINE_NUMBER
Include source line number on logline.
Definition: logging_api.hpp:1041
ReadBinaryLog::WANT_FORMAT
@ WANT_FORMAT
Definition: read_binary_log.hpp:24
LogLineBinaryHeader::argumentCount
uint32_t argumentCount
Definition: logging_api.hpp:176
OME_EXPECT_TRUE
#define OME_EXPECT_TRUE(expr)
Annotation macro for conditional expression expected to be true.
Definition: compiler_hints.h:541
ReadBinaryLog::timePointCache
TimePointCache * timePointCache
Definition: read_binary_log.hpp:34
LogLineBinaryValueHeader::argType
uint32_t argType
type of argument
Definition: logging_api.hpp:136
TimePointOfGranularity
Representation of localized expanded UNITS-since-epoch.
Definition: time_point.hpp:596
ReadMappedCircularBuffer::processEndOfBuffer
virtual int processEndOfBuffer()
Definition: read_binary_log.cpp:468
ReadBinaryLog::WANT_LINE_HEADER
@ WANT_LINE_HEADER
Definition: read_binary_log.hpp:24
POSIXtimeInUnits
Representation of UNITS-since-POSIX-epoch. This is an unambiguous time reference; there is no locale-...
Definition: time_point.hpp:313
LogLineBinaryHeader::nanosecondTimestamp
uint64_t nanosecondTimestamp
Definition: logging_api.hpp:170
LogLineBinaryValueHeader::argLength
uint32_t argLength
actual length of argument
Definition: logging_api.hpp:137
Read_And_Process_File
Fundamental class that can read data from a memory-mapped region, file or socket and process data in ...
Definition: read_file.hpp:244
LogLineBinaryValueHeader::headerLen
unsigned char headerLen
length of this header structure
Definition: logging_api.hpp:139
app
LogMaskType_t COMPONENT_LOG_MASK() app("app_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(app, defaultMask))
ReadBinaryLog::formatString
const char * formatString
Definition: read_binary_log.hpp:33
LogLineBinaryHeader::offsetFormatString
uint32_t offsetFormatString
Definition: logging_api.hpp:179
ReadBinaryLog::fileName
const char * fileName
Definition: read_binary_log.hpp:32
File_Buffer::discardInitialBytes
void discardInitialBytes(size_t bytes=0) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Discards bytes from the beginning of the active portion of the buffer; typically as a result of havin...
Definition: read_file.hpp:171
ReadMappedCircularBuffer::ReadMappedCircularBuffer
ReadMappedCircularBuffer(const char *fileName)
Definition: read_binary_log.cpp:432
ReadBinaryLog::argHeader
LogLineBinaryValueHeader * argHeader[LogMessageRecord::LOG_MAX_ARGUMENT_TOTAL]
Definition: read_binary_log.hpp:36
ReadBinaryLog::COPY_AS_IS
@ COPY_AS_IS
Definition: read_binary_log.hpp:25
ReadBinaryLog::setNewOutputDescriptor
OS_HANDLE_TYPE setNewOutputDescriptor(OS_HANDLE_TYPE newFD)
Definition: read_binary_log.hpp:56
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
LogMessageRecord::LOG_THREAD_ID
@ LOG_THREAD_ID
Include thread id on logline.
Definition: logging_api.hpp:1039
ReadBinaryLog::WANT_ARG_HEADER
@ WANT_ARG_HEADER
Definition: read_binary_log.hpp:24
LogMessageRecord::LOG_TIMESTAMP
@ LOG_TIMESTAMP
Include time on logline.
Definition: logging_api.hpp:1038
File_Buffer::spaceUsed
size_t spaceUsed() const OME_ALWAYS_INLINE
Returns the amount of space current used in the buffer.
Definition: read_file.hpp:125
CircularBufferManager
Impose a circular buffer on a BufferRegion.
Definition: circular_bfr.hpp:330
ReadMappedCircularBuffer::processRecord
virtual int processRecord(const unsigned char *data, size_t recLen)
Definition: read_binary_log.cpp:458
File_Buffer::startBufferLocation
unsigned char * startBufferLocation() const OME_ALWAYS_INLINE
Returns the start of the active content in the buffer.
Definition: read_file.hpp:131
LOG_COMPONENT_CERR
#define LOG_COMPONENT_CERR(component, lvl)
Convenience macro that uses LOG_COMPONENT_INTO to conditionally log a message to standard error.
Definition: logging_api.hpp:3030
SharedBufferAllocRecord_32::usedLen
uint32_t usedLen
Definition: circular_bfr.hpp:107
SharedBufferAllocRecord_32::blockLen
uint32_t blockLen
Definition: circular_bfr.hpp:106
_STDOUT_FD
#define _STDOUT_FD
Platform-independent reference to standard out.
Definition: logging_api.hpp:2616
ReadBinaryLog::~ReadBinaryLog
~ReadBinaryLog()
Definition: read_binary_log.hpp:52
Read_And_Process_File::recordsProcessed
uint32_t recordsProcessed
Definition: read_file.hpp:283
LogMessageRecord::LOG_DATESTAMP
@ LOG_DATESTAMP
Include date on logline.
Definition: logging_api.hpp:1037
LogMessageRecord::LOG_ARG_TYPE_HEX_FRAGMENT_UPPER
@ LOG_ARG_TYPE_HEX_FRAGMENT_UPPER
Definition: logging_api.hpp:1109
ReadMappedCircularBuffer::_pad
uint32_t _pad
Definition: read_binary_log.hpp:79
LOG_ENDLINE
#define LOG_ENDLINE
Closing clause for text line output using << operators.
Definition: logging_api.hpp:2956
LogLineBinaryHeader::offsetFileName
uint32_t offsetFileName
Definition: logging_api.hpp:177
ReadBinaryLog::parseOffset
uint32_t parseOffset
Definition: read_binary_log.hpp:28
OS_HANDLE_TYPE
#define OS_HANDLE_TYPE
Definition: io_processor.hpp:48
LogMessageRecord::LOG_ARG_TYPE_HEX_FRAGMENT
@ LOG_ARG_TYPE_HEX_FRAGMENT
Definition: logging_api.hpp:1108
byteAsUppercaseHexadecimal
const char byteAsUppercaseHexadecimal[256][3]
Table of uppercase hexadecimal characters for each byte value.
Definition: text2int.cpp:78
LogLineBinaryHeader::logLineLength
uint32_t logLineLength
Definition: logging_api.hpp:169
ReadBinaryLog::fileNameLen
uint32_t fileNameLen
Definition: read_binary_log.hpp:29
ReadMappedCircularBuffer::processRegionHeader
virtual int processRegionHeader(const SharedBufferRegionHeader *hdr, size_t segmentLen)
Definition: read_binary_log.cpp:463
ReadMappedCircularBuffer::processBlock
virtual int processBlock(const SharedBufferAllocRecord *record)
Definition: read_binary_log.cpp:474
uint_to_ascii
char * uint_to_ascii(uint32_t resultBfr[], uint_fast8_t bfrLen, uint64_t value, uint_fast8_t *retStrLen)
Quickly convert a binary integer into ASCII decimal text.
Definition: text2int.cpp:2628
LogMessageRecord::LOG_ARG_TYPE_DOUBLE
@ LOG_ARG_TYPE_DOUBLE
Definition: logging_api.hpp:1101
LOG_LINE_BINARY_FORMAT_VER1
@ LOG_LINE_BINARY_FORMAT_VER1
Denotes version of 1 of the header format.
Definition: logging_api.hpp:191
SharedMemoryVariableManager::createSegment
static unsigned char * createSegment(const char *fileName, size_t *segmentLengthPtr, int initMode=MAP_FILE_INIT, const char *desiredMagicNumber=SMV_MAGIC_NUMBER)
Open a file and map it to a memory segment for variable storage.
Definition: shared_variable.cpp:342
ReadBinaryLog::processBuffer
virtual int processBuffer(File_Buffer *bfrState) VIRTUAL_OVERRIDE
Process buffer contents.
Definition: read_binary_log.cpp:278
read_binary_log.hpp
Read binary log files.
fd
int fd
Definition: ethers.c:41
LOG_LINE_BINARY_FORMAT_LE
@ LOG_LINE_BINARY_FORMAT_LE
Indicates little-endian, IEEE 754 floating point format.
Definition: logging_api.hpp:193
Read_And_Process_File::intermediateBuffer
File_Buffer * intermediateBuffer
Definition: read_file.hpp:278
ReadBinaryLog::CHECK_FOR_BINARY_HEADER
@ CHECK_FOR_BINARY_HEADER
Definition: read_binary_log.hpp:25
LOG_CERR
#define LOG_CERR(lvl)
Convenience macro that uses LOG_INTO() to conditionally log a message to standard error.
Definition: logging_api.hpp:3014
logging_api.hpp
FARGOS Logging API.
Generated: Tue Jul 28 2020 16:03:26
Support Information