CCSDSPack
C++ Library for CCSDS Space Packet manipulation. i.e. generation, extraction, analisys and more
Loading...
Searching...
No Matches
Enumerations | Functions
exec_utils.h File Reference
#include <set>
#include "CCSDSResult.h"
#include <unordered_map>
Include dependency graph for exec_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ErrorCodeExec : std::uint8_t {
  ARG_PARSE_ERROR = 14 , CONFIG_MISSING_PARAMETER = 15 , INVALID_INPUT_DATA = 16 , OTHER = 17 ,
  PACKET_VALIDATION_FAILED = 18
}
 

Functions

CCSDS::ResultBool parseArguments (int argc, char *argv[], std::unordered_map< std::string, std::string > &allowedMap, std::unordered_map< std::string, std::string > &outArgs, const std::set< std::string > &booleanArgs)
 Parses the input arguments with defined values returns an unordered map with given keys and input values.
 
void customConsole (const std::string &appName, const std::string &message, const std::string &logLevel="INFO")
 Prints log to console adding various information about.
 

Enumeration Type Documentation

◆ ErrorCodeExec

enum ErrorCodeExec : std::uint8_t
Enumerator
ARG_PARSE_ERROR 

Error Parsing argument.

CONFIG_MISSING_PARAMETER 
INVALID_INPUT_DATA 
OTHER 
PACKET_VALIDATION_FAILED 

Definition at line 11 of file exec_utils.h.

11 : std::uint8_t {
12 ARG_PARSE_ERROR = 14,
15 OTHER = 17,
17};
@ CONFIG_MISSING_PARAMETER
Definition exec_utils.h:13
@ PACKET_VALIDATION_FAILED
Definition exec_utils.h:16
@ ARG_PARSE_ERROR
Error Parsing argument.
Definition exec_utils.h:12
@ INVALID_INPUT_DATA
Definition exec_utils.h:14
@ OTHER
Definition exec_utils.h:15

Function Documentation

◆ customConsole()

void customConsole ( const std::string &  appName,
const std::string &  message,
const std::string &  logLevel = "INFO" 
)

Prints log to console adding various information about.

Parameters
appName
message
logLevel

Definition at line 51 of file exec_utils.cpp.

51 {
52 // Get current timestamp with high precision
53 const auto now = std::chrono::high_resolution_clock::now();
54 const auto duration = now.time_since_epoch();
55 const auto microseconds = std::chrono::duration_cast<std::chrono::microseconds>(duration);
56
57 // Get the current system time for date and time portion
58 const std::time_t currentTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
59 const std::tm* tm = std::localtime(&currentTime);
60
61 // Format timestamp (YYYY-MM-DD HH:MM:SS)
62 std::ostringstream timestampStream;
63 timestampStream << std::put_time(tm, "%Y-%m-%d %H:%M:%S");
64
65 // Output log with timestamp, application name, log level, and microseconds
66 std::cout << "[" << timestampStream.str() << "."
67 << std::setw(6) << std::setfill('0') << microseconds.count() % 1000000 // last 6 digits (microseconds)
68 << "] [" << appName << "] "
69 << "[" << logLevel << "] : "
70 << message << std::endl;
71}
Here is the caller graph for this function:

◆ parseArguments()

CCSDS::ResultBool parseArguments ( int  argc,
char *  argv[],
std::unordered_map< std::string, std::string > &  allowedMap,
std::unordered_map< std::string, std::string > &  outArgs,
const std::set< std::string > &  booleanArgs 
)

Parses the input arguments with defined values returns an unordered map with given keys and input values.

boolean Args do not require values associated with them.

Parameters
argc
argv
allowedMap
outArgs
booleanArgs
Returns
CCSDS::ResultBool
Here is the caller graph for this function: