Commit a3fad7da authored by Romain Bignon's avatar Romain Bignon

stuffs about log flags

parent c4ce72d5
......@@ -104,7 +104,7 @@ logging {
# INFO :Information
# ALL :Show all infos
# You can put several logging level on the same line, separated by a space
level = DESYNCH WARNING ERR CONNEC INFO
level = INFO ERR WARNING DESYNCH
# Wether to log errors and warning to syslog
to_syslog = true
......
......@@ -142,7 +142,7 @@ IRC::IRC(ServerPoll* _poll, int _fd, string _hostname, unsigned _ping_freq)
ping_id = g_timeout_add_seconds((int)ping_freq, g_callback, ping_cb);
}
rehash();
rehash(false);
user->send(Message(MSG_NOTICE).setSender(this).setReceiver("AUTH").addArg("Minbif-IRCd initialized, please go on"));
}
......@@ -210,7 +210,7 @@ void IRC::cleanUpDCC()
void IRC::addChannel(Channel* chan)
{
if(channels.find(chan->getName()) != channels.end())
b_log[W_ERR] << "!!!!!WARNING!!!!! Channel " << chan->getName() << " already exists!";
b_log[W_DESYNCH] << "/!\\ Channel " << chan->getName() << " already exists!";
channels[chan->getName()] = chan;
}
......@@ -244,7 +244,7 @@ void IRC::cleanUpChannels()
void IRC::addNick(Nick* nick)
{
if(users.find(nick->getNickname()) != users.end())
b_log[W_ERR] << "!!!!!WARNING!!!!! User " << nick->getNickname() << " already exists!";
b_log[W_DESYNCH] << "/!\\ User " << nick->getNickname() << " already exists!";
users[nick->getNickname()] = nick;
}
......@@ -357,10 +357,11 @@ void IRC::cleanUpServers()
servers.clear();
}
void IRC::rehash()
void IRC::rehash(bool verbose)
{
setMotd(conf.GetSection("path")->GetItem("motd")->String());
b_log[W_INFO|W_SNO] << "Server configuration rehashed.";
if(verbose)
b_log[W_INFO|W_SNO] << "Server configuration rehashed.";
}
void IRC::setMotd(const string& path)
......@@ -508,6 +509,7 @@ bool IRC::readIO(void*)
++i)
;
b_log[W_PARSE] << "IRC::R - " << line;
user->setLastReadNow();
if(i >= (sizeof commands / sizeof *commands))
......
......@@ -159,7 +159,7 @@ namespace irc
Channel* getChannel(string channame) const;
void removeChannel(string channame);
void rehash();
void rehash(bool verbose = true);
void setMotd(const string& path);
void addNick(Nick* nick);
......
......@@ -19,6 +19,7 @@
#include <cstdio>
#include "user.h"
#include "server.h"
#include "../log.h"
namespace irc {
......@@ -39,6 +40,7 @@ void User::send(Message msg)
if(fd >= 0)
{
string s = msg.format();
b_log[W_PARSE] << "IRC::S - " << s;
write(fd, s.c_str(), s.size());
}
}
......
......@@ -31,16 +31,17 @@ static struct
uint32_t flag;
int level;
const char* s;
bool sys_log;
} all_flags[] =
{
{ W_SNO, LOG_NOTICE, "" },
{ W_DEBUG, LOG_DEBUG, "DEBUG" },
{ W_PARSE, LOG_DEBUG, "PARSE" },
{ W_PURPLE, LOG_DEBUG, "PURPLE" },
{ W_DESYNCH, LOG_WARNING, "DESYNCH" },
{ W_WARNING, LOG_WARNING, "WARNING" },
{ W_ERR, LOG_ERR, "ERR" },
{ W_INFO, LOG_NOTICE, "INFO" },
{ W_SNO, LOG_NOTICE, "" , false },
{ W_DEBUG, LOG_DEBUG, "DEBUG" , false },
{ W_PARSE, LOG_DEBUG, "PARSE" , false },
{ W_PURPLE, LOG_DEBUG, "PURPLE" , false },
{ W_DESYNCH, LOG_WARNING, "DESYNCH", false },
{ W_WARNING, LOG_WARNING, "WARNING", false },
{ W_ERR, LOG_ERR, "ERR" , true },
{ W_INFO, LOG_NOTICE, "INFO" , false },
};
Log::flux::~flux()
......@@ -57,7 +58,7 @@ Log::flux::~flux()
syslog(LOG_WARNING, "[SYSLOG] (%X) Unable to find how to log this message: %s", (uint32_t)flag, str.c_str());
else
{
if((all_flags[i].level == LOG_ERR || all_flags[i].level == LOG_WARNING) && b_log.ToSyslog())
if(all_flags[i].sys_log && b_log.ToSyslog())
syslog(all_flags[i].level, "[%s] %s", all_flags[i].s, str.c_str());
struct timeval t;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment