LCOV - code coverage report
Current view: top level - libMagAOX/logger/types - empty_log.hpp (source / functions) Coverage Total Hit
Test: MagAOX Lines: 84.6 % 13 11
Test Date: 2026-01-03 21:03:39 Functions: 83.3 % 6 5

            Line data    Source code
       1              : /** \file empty_log.hpp
       2              :   * \brief The MagAO-X logger empty log base type.
       3              :   * \author Jared R. Males (jaredmales@gmail.com)
       4              :   *
       5              :   * \ingroup logger_types_files
       6              :   *
       7              :   * History:
       8              :   * - 2018-08-18 created by JRM
       9              :   */
      10              : #ifndef logger_types_empty_log_hpp
      11              : #define logger_types_empty_log_hpp
      12              : 
      13              : #include "../logMeta.hpp"
      14              : 
      15              : #include "flatbuffer_log.hpp"
      16              : 
      17              : namespace MagAOX
      18              : {
      19              : namespace logger
      20              : {
      21              : 
      22              : 
      23              : ///Empty type for resolving logs with no message.
      24              : /**
      25              :   * \ingroup logger_types_basic
      26              :   */
      27              : struct emptyMessage
      28              : {
      29              : };
      30              : 
      31              : 
      32              : /// Base class for logs consisting of an empty message.
      33              : /** Such logs are used to log events. Does not have eventCode or defaultLevel,
      34              :   * so this can not be used as a log type directly.
      35              :   *
      36              :   *
      37              :   * \ingroup logger_types_basic
      38              :   */
      39              : template<class derivedT>
      40              : struct empty_log
      41              : {
      42              :    ///The type of the message
      43              :    typedef emptyMessage messageT;
      44              : 
      45              :    ///Get the length of the message.
      46           16 :    static flatlogs::msgLenT length( const messageT & msg)
      47              :    {
      48              :       static_cast<void>(msg);
      49              : 
      50           16 :       return 0;
      51              :    }
      52              : 
      53              :    ///Format the buffer given a message -- a no-op since the message is an emptyMessage.
      54              :    /**
      55              :      * \returns 0
      56              :      */
      57           11 :    static int format( void * msgBuffer,    ///< [out] the buffer, which is ignored.
      58              :                       const messageT & msg ///< [in] an emptyMessage.
      59              :                     )
      60              :    {
      61              :       static_cast<void>(msgBuffer);
      62              :       static_cast<void>(msg);
      63              : 
      64           11 :       return 0;
      65              :    }
      66              : 
      67              :    ///Extract the message from a buffer -- a no-op since it is an emptyMessage.
      68              :    /**
      69              :      * \returns 0
      70              :      */
      71              :    static int extract( messageT & msg,      ///< [out] an emptyMessage to which nothing is done.
      72              :                        void * msgBuffer,    ///< [in] the empty buffer.  Is ignored.
      73              :                        flatlogs::msgLenT len ///< [in] ignored length of the empty buffer.
      74              :                      )
      75              :    {
      76              :       static_cast<void>(msg);
      77              :       static_cast<void>(msgBuffer);
      78              :       static_cast<void>(len);
      79              : 
      80              : 
      81              :       return 0;
      82              :    }
      83              : 
      84            5 :    static bool verify( flatlogs::bufferPtrT & logBuff,  ///< [in] Buffer containing the flatbuffer serialized message.
      85              :                        flatlogs::msgLenT len            ///< [in] length of msgBuffer.
      86              :                      )
      87              :    {
      88              :       static_cast<void>(logBuff);
      89            5 :       return (len == 0);
      90              :    }
      91              : 
      92            6 :    static std::string msgString( void * msgBuffer, flatlogs::msgLenT len)//messageT & msg  /**< [in] [unused] the empty message */)
      93              :    {
      94              :       static_cast<void>(msgBuffer);
      95              :       static_cast<void>(len);
      96              : 
      97           12 :       return derivedT::msg();
      98              :    }
      99              : 
     100            0 :    static std::string msgJSON( void * msgBuffer,  /**< [in] Buffer containing the flatbuffer serialized message.*/
     101              :                                flatlogs::msgLenT len,  /**< [in] [unused] length of msgBuffer.*/
     102              :                                const uint8_t * binarySchema, /**< [in] [unused] */
     103              :                                const unsigned int binarySchemaLength /**< [in] [unused] */
     104              :                               )
     105              :    {
     106              :       static_cast<void>(len);
     107              :       static_cast<void>(msgBuffer);
     108              :       static_cast<void>(binarySchema);
     109              :       static_cast<void>(binarySchemaLength);
     110            0 :       return "{}";
     111              :    }
     112              : 
     113              :    /// Get an empty logMetaDetail because meta data doesn't make sense for this log
     114              :    /**
     115              :      * \returns an empty logMetaDetail
     116              :      */
     117            5 :    static logMetaDetail getAccessor( const std::string & member /**< [in] the name of the member */ )
     118              :    {
     119              :       static_cast<void>(member);
     120              : 
     121            5 :       std::cerr << "meta data doesn't make sense for " << eventCodeName(derivedT::eventCode) << "\n";
     122            5 :       return logMetaDetail();
     123              :    }
     124              : };
     125              : 
     126              : } //namespace logger
     127              : } //namespace MagAOX
     128              : 
     129              : #endif //logger_types_empty_log_hpp
        

Generated by: LCOV version 2.0-1