#include "msg/Message.h"
#include "messages/MLog.h"
+#include "mon/MonMap.h"
#include <iostream>
#include <errno.h>
#include "common/LogClient.h"
-
#include "config.h"
-void LogClient::log(__u8 level, string s)
+void LogClient::log(log_type type, string s)
{
Mutex::Locker l(log_lock);
- dout(10) << "log " << (int)level << " : " << s << dendl;
+ dout(10) << "log " << (log_type)type << " : " << s << dendl;
LogEntry e;
e.who = messenger->get_myinst();
e.stamp = g_clock.now();
e.seq = ++last_log;
- e.level = level;
+ e.type = type;
e.msg = s;
log_queue.push_back(e);
}
#include "msg/Dispatcher.h"
#include "common/Mutex.h"
-#include "common/RWLock.h"
-#include "common/ThreadPool.h"
-#include "common/Timer.h"
-#include "common/WorkQueue.h"
-
-#include "mon/MonMap.h"
-
-#include "os/ObjectStore.h"
-
-#include "common/DecayCounter.h"
-
#include "include/LogEntry.h"
-#include <map>
-using namespace std;
-
-#include <ext/hash_map>
-#include <ext/hash_set>
-using namespace __gnu_cxx;
-
-
class Messenger;
-class Message;
-class Logger;
-class ObjectStore;
-class OSDMap;
class MLog;
+class MonMap;
+
class LogClient {
Messenger *messenger;
deque<LogEntry> log_queue;
version_t last_log;
- void log(__u8 level, string s);
+ void log(log_type type, string s);
void send_log();
void handle_log(MLog *m);
#include "include/types.h"
#include "include/encoding.h"
+typedef enum {
+ LOG_DEBUG = 0,
+ LOG_INFO = 1,
+ LOG_WARN = 2,
+ LOG_ERROR = 3,
+} log_type;
+
struct LogEntry {
entity_inst_t who;
utime_t stamp;
__u64 seq;
- __u8 level;
+ log_type type;
string msg;
void encode(bufferlist& bl) const {
+ __u16 t = type;
::encode(who, bl);
::encode(stamp, bl);
::encode(seq, bl);
- ::encode(level, bl);
+ ::encode(t, bl);
::encode(msg, bl);
}
void decode(bufferlist::iterator& bl) {
+ __u16 t;
::decode(who, bl);
::decode(stamp, bl);
::decode(seq, bl);
- ::decode(level, bl);
+ ::decode(t, bl);
+ type = (log_type)t;
::decode(msg, bl);
}
};
WRITE_CLASS_ENCODER(LogEntry)
+inline ostream& operator<<(ostream& out, const log_type& t)
+{
+ switch (t) {
+ case LOG_DEBUG:
+ return out << "[DBG]";
+ case LOG_INFO:
+ return out << "[INF]";
+ case LOG_WARN:
+ return out << "[WRN]";
+ case LOG_ERROR:
+ return out << "[ERR]";
+ default:
+ return out << "[???]";
+ }
+}
+
inline ostream& operator<<(ostream& out, const LogEntry& e)
{
- return out << e.stamp << " " << e.who << " : " << e.seq << " : " << (int)e.level << " : " << e.msg;
+ return out << e.stamp << " " << e.type << " " << e.who << " : " << e.seq << " : " << e.msg;
}
#endif
LogEntry e;
memset(&e.who, 0, sizeof(e.who));
e.stamp = g_clock.now();
- e.level = 0;
+ e.type = LOG_INFO;
e.msg = "mkfs";
e.seq = 0;
stringstream ss;
ss << "scrub " << info.pgid << " " << num_missing << " missing, " << num_bad << " bad objects";
string s;
getline(ss, s);
- osd->get_logclient()->log(10, s);
+ osd->get_logclient()->log(LOG_ERROR, s);
}
// discard peer scrub info.
<< stat.num_kb << "/" << info.stats.num_kb << " kb.";
string s;
getline(ss, s);
- osd->get_logclient()->log(10, s);
+ osd->get_logclient()->log(LOG_ERROR, s);
/*
} else {
stringstream ss;