Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef LOGGER_H
00014 #define LOGGER_H
00015
00016 #include "anope.h"
00017 #include "defs.h"
00018
00019 enum LogType
00020 {
00021
00022 LOG_ADMIN,
00023
00024
00025
00026 LOG_OVERRIDE,
00027
00028 LOG_COMMAND,
00029 LOG_SERVER,
00030 LOG_CHANNEL,
00031 LOG_USER,
00032 LOG_MODULE,
00033 LOG_NORMAL,
00034 LOG_TERMINAL,
00035 LOG_RAWIO,
00036 LOG_DEBUG,
00037 LOG_DEBUG_2,
00038 LOG_DEBUG_3,
00039 LOG_DEBUG_4
00040 };
00041
00042 struct LogFile
00043 {
00044 Anope::string filename;
00045 std::ofstream stream;
00046
00047 LogFile(const Anope::string &name);
00048 Anope::string GetName() const;
00049 };
00050
00051
00052 class CoreExport Log
00053 {
00054 public:
00055
00056 const BotInfo *bi;
00057
00058 Anope::string nick;
00059
00060 const User *u;
00061
00062 const NickCore *nc;
00063
00064 Command *c;
00065
00066 Channel *chan;
00067
00068 const ChannelInfo *ci;
00069
00070 Server *s;
00071
00072 Module *m;
00073 LogType type;
00074 Anope::string category;
00075 std::list<Anope::string> sources;
00076
00077 std::stringstream buf;
00078
00079 Log(LogType type = LOG_NORMAL, const Anope::string &category = "", const BotInfo *bi = NULL);
00080
00081
00082 Log(LogType type, CommandSource &source, Command *c, const ChannelInfo *ci = NULL);
00083
00084
00085 Log(const User *u, Channel *c, const Anope::string &category = "");
00086
00087
00088 explicit Log(const User *u, const Anope::string &category = "", const BotInfo *bi = NULL);
00089
00090
00091 explicit Log(Server *s, const Anope::string &category = "", const BotInfo *bi = NULL);
00092
00093 explicit Log(const BotInfo *b, const Anope::string &category = "");
00094
00095 Log(Module *m, const Anope::string &category = "");
00096
00097 ~Log();
00098
00099 Anope::string BuildPrefix() const;
00100
00101 template<typename T> Log &operator<<(T val)
00102 {
00103 this->buf << val;
00104 return *this;
00105 }
00106 };
00107
00108
00109 class CoreExport LogInfo
00110 {
00111 public:
00112 std::list<Anope::string> targets;
00113 std::map<Anope::string, LogFile *> logfiles;
00114 std::list<Anope::string> sources;
00115 int log_age;
00116 std::list<Anope::string> admin;
00117 std::list<Anope::string> override;
00118 std::list<Anope::string> commands;
00119 std::list<Anope::string> servers;
00120 std::list<Anope::string> users;
00121 std::list<Anope::string> channels;
00122 std::list<Anope::string> normal;
00123 bool raw_io;
00124 bool debug;
00125
00126 LogInfo(int logage, bool rawio, bool debug);
00127
00128 ~LogInfo();
00129
00130 void AddType(std::list<Anope::string> &list, const Anope::string &type);
00131
00132 bool HasType(LogType ltype, const Anope::string &type) const;
00133
00134
00135 void ProcessMessage(const Log *l);
00136 };
00137
00138 #endif // LOGGER_H
00139