1 #include <rtt/Service.hpp> 2 #include <rtt/Logger.hpp> 5 #include <rtt/types/GlobalsRepository.hpp> 6 #include <rtt/types/Types.hpp> 7 #include <rtt/types/TypeInfoName.hpp> 8 #include <rtt/plugin/ServicePlugin.hpp> 22 RTT::Service(
"print", parent)
24 doc(
"A service that provides basic printing to std::cout, std::cerr and the RTT::Logger.");
26 addOperation(
"ln", &PrintService::println,
this).doc(
27 "Prints a line to standard output.").arg(
"line",
28 "A string. Use a '+' to mix strings with numbers/variables.");
29 addOperation(
"err", &PrintService::printerr,
this).doc(
30 "Prints a line to standard error.").arg(
"line",
31 "A string. Use a '+' to mix strings with numbers/variables.");
32 addOperation(
"log", &PrintService::printlog,
this).doc(
33 "Prints a line to Orocos logger class.").arg(
"level",
"The LogLevel to use.").arg(
"line",
34 "A string. Use a '+' to mix strings with numbers/variables.");
37 if (types::Types()->type(
"LogLevel") == 0) {
38 types::Types()->addType(
new types::TypeInfoName<Logger::LogLevel>(
"LogLevel") );
39 types::GlobalsRepository::shared_ptr globals = types::GlobalsRepository::Instance();
43 globals->setValue(
new Constant<Logger::LogLevel>(
"Never",Logger::Never) );
44 globals->setValue(
new Constant<Logger::LogLevel>(
"Error",Logger::Error) );
45 globals->setValue(
new Constant<Logger::LogLevel>(
"Fatal",Logger::Fatal) );
46 globals->setValue(
new Constant<Logger::LogLevel>(
"Critical",Logger::Critical) );
47 globals->setValue(
new Constant<Logger::LogLevel>(
"Warning",Logger::Warning) );
48 globals->setValue(
new Constant<Logger::LogLevel>(
"Info",Logger::Info) );
49 globals->setValue(
new Constant<Logger::LogLevel>(
"Debug",Logger::Debug) );
50 globals->setValue(
new Constant<Logger::LogLevel>(
"RealTime",Logger::RealTime) );
54 void println(
const std::string& arg)
56 std::cout << arg << std::endl;
58 void printerr(
const std::string& arg)
60 std::cerr << arg << std::endl;
62 void printlog(Logger::LogLevel level,
const std::string& arg)
64 log(LoggerLevel(level)) << arg <<endlog();
A service that provides basic printing to std::cout, std::cerr and the RTT::Logger.
The Orocos Component Library.