Skyward boardcore
Loading...
Searching...
No Matches
Boardcore::Logger Class Reference

Buffered logger. Needs to be started before it can be used. More...

#include <Logger.h>

Inheritance diagram for Boardcore::Logger:
Collaboration diagram for Boardcore::Logger:

Public Member Functions

bool start ()
 Call this function to start the logger.
 
void stop ()
 Call this function to stop the logger.
 
int getCurrentLogNumber ()
 
std::string getCurrentFileName ()
 
LoggerStats getStats ()
 
void resetStats ()
 
bool isStarted () const
 
template<typename T >
LoggerResult log (const T &t)
 Call this function to log a class.
 
void logStats ()
 Log logger stats using the logger itself.
 
- Public Member Functions inherited from Boardcore::Singleton< Logger >
 Singleton (const Singleton &)=delete
 
Singletonoperator= (const Singleton &)=delete
 

Static Public Member Functions

static bool testSDCard ()
 Tests if the Logger can write to the SD card by opening a file.
 
static constexpr unsigned int getMaxFilenameNumber ()
 Returns the Max Filename number.
 
- Static Public Member Functions inherited from Boardcore::Singleton< Logger >
static LoggergetInstance ()
 

Friends

class Singleton< Logger >
 

Additional Inherited Members

- Protected Member Functions inherited from Boardcore::Singleton< Logger >
 Singleton ()
 

Detailed Description

Buffered logger. Needs to be started before it can be used.

Definition at line 54 of file Logger.h.

Member Function Documentation

◆ getCurrentFileName()

string Boardcore::Logger::getCurrentFileName ( )

Definition at line 140 of file Logger.cpp.

◆ getCurrentLogNumber()

int Boardcore::Logger::getCurrentLogNumber ( )

Definition at line 138 of file Logger.cpp.

◆ getMaxFilenameNumber()

static constexpr unsigned int Boardcore::Logger::getMaxFilenameNumber ( )
inlinestaticconstexpr

Returns the Max Filename number.

Definition at line 130 of file Logger.h.

◆ getStats()

LoggerStats Boardcore::Logger::getStats ( )

Definition at line 142 of file Logger.cpp.

◆ isStarted()

bool Boardcore::Logger::isStarted ( ) const

Definition at line 163 of file Logger.cpp.

◆ log()

template<typename T >
LoggerResult Boardcore::Logger::log ( const T & t)

Call this function to log a class.

Nonblocking call.

Refer to the TSCPP repository to know more about how the data is stored. https://git.skywarder.eu/scs/third-party/tscpp

Parameters
TThe class to be logged. This class has the following requirements:
  • it must be trivially_copyable, so no pointers or references inside the class, no stl containers, no virtual functions, no base classes.
  • it must have a "void print(std::ostream& os) const" member function that prints all its data fields in text form (this is not used by the logger, but by the log decoder program)
Returns
Whether the class has been logged.

Definition at line 224 of file Logger.h.

◆ logStats()

void Boardcore::Logger::logStats ( )

Log logger stats using the logger itself.

The stats are reset after being logged.

Definition at line 165 of file Logger.cpp.

◆ resetStats()

void Boardcore::Logger::resetStats ( )

Definition at line 149 of file Logger.cpp.

◆ start()

bool Boardcore::Logger::start ( )

Call this function to start the logger.

Tries to start the logger, first opens the log file and then create the pack and write threads. If it fails on one of this operation, the logger is not started.

Use getCurrentLogNumber to retrieve the log file number.

Blocking call. May take a long time.

Returns
True if the logger was started correctly.

Definition at line 46 of file Logger.cpp.

◆ stop()

void Boardcore::Logger::stop ( )

Call this function to stop the logger.

When this function returns, all log buffers have been flushed to disk, and it is safe to power down the board without losing log data or corrupting the filesystem.

Blocking call. May take a very long time (seconds).

Definition at line 111 of file Logger.cpp.

◆ testSDCard()

bool Boardcore::Logger::testSDCard ( )
static

Tests if the Logger can write to the SD card by opening a file.

Definition at line 131 of file Logger.cpp.

Friends And Related Symbol Documentation

◆ Singleton< Logger >

friend class Singleton< Logger >
friend

Definition at line 224 of file Logger.h.


The documentation for this class was generated from the following files: