DiagnosticUtils.cpp

Go to the documentation of this file.
00001 // Copyright CERN 2012 - Developed in collaboration with GSI
00002 
00003 #include <fesa-core/Diagnostic/DiagnosticUtils.h>
00004 
00005 #include <sstream>
00006 #include <cassert>
00007 
00008 
00009 namespace fesa
00010 {
00011 
00012 std::string
00013 DiagnosticUtils::convertFwkTopicToString(FrameworkTopic topic)
00014 {
00015     switch (topic)
00016     {
00017         case getActionProfiling:
00018             return getActionProfilingStr;
00019         case setActionProfiling:
00020             return setActionProfilingStr;
00021         case rtActionProfiling:
00022             return rtActionProfilingStr;
00023         case eventProfiling:
00024             return eventProfilingStr;
00025         case notificationProfiling:
00026             return notificationProfilingStr;
00027         case getActionTracking:
00028             return getActionTrackingStr;
00029         case setActionTracking:
00030             return setActionTrackingStr;
00031         case rtActionTracking:
00032             return rtActionTrackingStr;
00033         case eventTracking:
00034             return eventTrackingStr;
00035         case notificationTracking:
00036             return notificationTrackingStr;
00037         case persistencyTracking:
00038             return persistencyTrackingStr;
00039         case transactionTracking:
00040             return transactionTrackingStr;
00041         case subscriptionTracking:
00042             return subscriptionTrackingStr;
00043         case signalHandlerTracking:
00044             return signalHandlerTrackingStr;
00045         case rdaTracking:
00046             return rdaTrackingStr;
00047         case startUpTracking:
00048             return startUpTrackingStr;
00049         default:
00050             assert(false);
00051     }
00052 }
00053 
00054 
00055 std::string
00056 DiagnosticUtils::convertActionToString(Action action)
00057 {
00058     switch (action)
00059     {
00060         case undefined:
00061             return "-";
00062         case start:
00063             return "START";
00064         case stop:
00065             return "STOP";
00066         default:
00067             assert(false);
00068     }
00069 }
00070 
00071 
00072 std::string
00073 DiagnosticUtils::convertSideToString(Side side)
00074 {
00075     switch (side)
00076     {
00077         case framework:
00078             return "FWK";
00079         case user:
00080             return "USR";
00081         default:
00082             assert(false);
00083     }
00084 }
00085 
00086 
00087 std::string
00088 DiagnosticUtils::convertSourceToString(Source source)
00089 {
00090     switch (source)
00091     {
00092         case main:
00093             return "MAIN";
00094         case rt:
00095             return "RT";
00096         case server:
00097             return "SRV";
00098         case event:
00099             return "EVT";
00100         case notification:
00101             return "NOTIF";
00102         default:
00103             assert(false);
00104     }
00105 }
00106 
00107 std::string
00108 DiagnosticUtils::formatMessage(const DiagnosticMessage& diagMsg)
00109 {
00110     std::string name(diagMsg.name);
00111     if (name.empty() == true)
00112     {
00113         name = "-";
00114     }
00115     std::ostringstream msgStream;
00116     msgStream << "|TRACE|" << convertSideToString(diagMsg.side) << "-" << convertSourceToString(diagMsg.source) <<
00117         "|-|" << diagMsg.thread << "|" << diagMsg.count << "|-|" << name + "|" << convertActionToString(diagMsg.action) <<
00118         "|" << diagMsg.msg;
00119 
00120     return msgStream.str();
00121 }
00122 
00123 } // fesa

Generated on 18 Jan 2013 for Fesa by  doxygen 1.6.1