Browse Source

[trac901] The impl can output and lookup message

Michal 'vorner' Vaner 14 years ago
parent
commit
121d3e844a
2 changed files with 22 additions and 0 deletions
  1. 20 0
      src/lib/log/logger_impl.cc
  2. 2 0
      src/lib/log/logger_impl.h

+ 20 - 0
src/lib/log/logger_impl.cc

@@ -194,6 +194,26 @@ LoggerImpl::isDebugEnabled(int dbglevel) {
 }
 
 // Output a general message
+string*
+LoggerImpl::lookupMessage(const MessageID& ident) {
+    return (new string(string(ident) + ", " +
+                       MessageDictionary::globalDictionary().getText(ident)));
+}
+
+void
+LoggerImpl::outputRaw(const char* sevText, const string& message) {
+    // Get the time in a struct tm format, and convert to text
+    time_t t_time;
+    time(&t_time);
+    struct tm* tm_time = localtime(&t_time);
+
+    char chr_time[32];
+    (void) strftime(chr_time, sizeof(chr_time), "%Y-%m-%d %H:%M:%S", tm_time);
+
+    // Now output.
+    cout << chr_time << " " << sevText << " [" << getName() << "] " <<
+        message << endl;
+}
 
 void
 LoggerImpl::output(const char* sev_text, const MessageID& ident,

+ 2 - 0
src/lib/log/logger_impl.h

@@ -179,6 +179,8 @@ public:
     void output(const char* sev_text, const MessageID& ident,
         va_list ap);
 
+    void outputRaw(const char* sev_text, const std::string& message);
+    std::string* lookupMessage(const MessageID& id);
 
     /// \brief Output Debug Message
     ///