2023-04-18 21:27:32 +00:00
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "trick/MessageCustomFile.hh"
|
|
|
|
#include "trick/Message_proto.hh"
|
|
|
|
|
|
|
|
|
|
|
|
int Trick::MessageCustomFile::level_counter = 200;
|
|
|
|
|
|
|
|
/**
|
|
|
|
@details
|
|
|
|
-# Initializes everything
|
|
|
|
*/
|
2023-04-28 20:42:42 +00:00
|
|
|
Trick::MessageCustomFile::MessageCustomFile() : _this_level(level_counter++) {
|
2023-04-18 21:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
@details
|
|
|
|
-# If enabled and level is this file's level
|
|
|
|
-# Write the header and message to the file stream
|
|
|
|
-# Flush the stream
|
|
|
|
*/
|
|
|
|
void Trick::MessageCustomFile::update( unsigned int level , std::string header, std::string message ) {
|
2023-04-28 20:42:42 +00:00
|
|
|
if ( enabled && level == _this_level ) {
|
2023-04-18 21:27:32 +00:00
|
|
|
out_stream << header << message ;
|
|
|
|
out_stream.flush() ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-28 20:42:42 +00:00
|
|
|
int Trick::MessageCustomFile::get_level() const {
|
|
|
|
return _this_level;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Trick::MessageCustomFile::set_level(int level) {
|
|
|
|
if (level >= 0)
|
|
|
|
_this_level = level;
|
2023-04-18 21:27:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Trick::MessageCustomFile::set_name(std::string name) {
|
|
|
|
if (name == "") {
|
2023-04-28 20:42:42 +00:00
|
|
|
name = "CustomLog" + std::to_string(_this_level);
|
2023-04-18 21:27:32 +00:00
|
|
|
}
|
|
|
|
this->name = name;
|
|
|
|
}
|
|
|
|
void Trick::MessageCustomFile::set_file_name(std::string file_name) {
|
|
|
|
this->file_name = file_name;
|
|
|
|
}
|
|
|
|
|
|
|
|
|