mirror of
https://github.com/nasa/trick.git
synced 2024-12-22 06:27:49 +00:00
19025d77ad
Reorganized. Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory. Created a libexec directory that holds all of the executables that users don't need to execute directly. Changed all of the executables remaining in bin to start with "trick-". In the sim_services directories changed all source files to find the Trick headers in their new location. Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level. Moved the makefiles, docs, man, and other architecture independent files into a top level share directory. Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on. refs #63
55 lines
1.5 KiB
C++
55 lines
1.5 KiB
C++
|
|
#include "trick/MessageCout.hh"
|
|
#include "trick/message_type.h"
|
|
|
|
#include <sstream>
|
|
|
|
Trick::MessageCout::MessageCout() {
|
|
/** By default, this subscriber is enabled when it is created. */
|
|
enabled = 1 ;
|
|
color = 1 ;
|
|
name = "cout" ;
|
|
}
|
|
|
|
void Trick::MessageCout::update( unsigned int level , std::string header , std::string message ) {
|
|
|
|
/** @par Design Details: */
|
|
std::string color_code ;
|
|
|
|
switch (level) {
|
|
case MSG_NORMAL :
|
|
color_code = "\033[00m" ; // normal
|
|
break ;
|
|
case MSG_INFO :
|
|
color_code = "\033[32m" ; // green
|
|
break ;
|
|
case MSG_WARNING :
|
|
color_code = "\033[33m" ; // yellow
|
|
break ;
|
|
case MSG_ERROR :
|
|
color_code = "\033[31m" ; // red
|
|
break ;
|
|
case MSG_DEBUG :
|
|
color_code = "\033[36m" ; // cyan
|
|
break ;
|
|
default :
|
|
color_code = "\033[00m" ; // normal
|
|
break ;
|
|
}
|
|
|
|
/** @li Prints the received message to the standard output stream. */
|
|
if (enabled && level < 100 ) {
|
|
|
|
// Building the final string in a temporary stream ensures an automic call to cout, which prevents
|
|
// multithreaded sims from interleaving header and message elements.
|
|
std::ostringstream oss;
|
|
if ( color ) {
|
|
oss << header << color_code << message << "\033[00m" ;
|
|
} else {
|
|
oss << header << message ;
|
|
}
|
|
std::cout << oss.str() << std::flush;
|
|
}
|
|
}
|
|
|