Ignore:
Timestamp:
04/26/15 00:59:09 (9 years ago)
Author:
Maciej Komosinski
Message:

Renamed logging functions to more intuitive and simple names

Location:
cpp/frams/loggers
Files:
1 copied
1 moved

Legend:

Unmodified
Added
Removed
  • cpp/frams/loggers/loggers.h

    r374 r375  
    33// See LICENSE.txt for details.
    44
    5 #ifndef _MHANDLERS_H_
    6 #define _MHANDLERS_H_
     5#ifndef _FRAMS_LOGGERS_H_
     6#define _FRAMS_LOGGERS_H_
    77
    88#include <frams/util/list.h>
    99#include <frams/util/sstring.h>
    10 #include <common/hmessage.h>
     10#include <common/log.h>
    1111#include <common/threads.h>
    1212
    13 class MessageHandlerBase;
     13class LoggerBase;
    1414
    15 class MessageHandlerManager
     15class LoggerManager
    1616{
    17         friend class MessageHandlerBase;
    18         SListTempl<MessageHandlerBase*> handlers;
    19         void send(int level, const char *o, const char *m, const char *bl, int w);
     17        friend class LoggerBase;
     18        SListTempl<LoggerBase*> handlers;
     19        void send(int level, const char *o, const char *m, int w, const char *bl);
    2020public:
    21         int find(MessageHandlerBase *r) { return handlers.find(r); }
    22         int add(MessageHandlerBase *r);
     21        int find(LoggerBase *r) { return handlers.find(r); }
     22        int add(LoggerBase *r);
    2323        void remove(int i);
    24         void remove(MessageHandlerBase *r);
     24        void remove(LoggerBase *r);
    2525        void removeAll();
    26         void send(const char *o, const char *m, const char *bl, int w)
     26        void send(const char *o, const char *m, int w, const char *bl)
    2727        {
    28                 send(handlers.size() - 1, o, m, bl, w);
     28                send(handlers.size() - 1, o, m, w, bl);
    2929        }
    30         ~MessageHandlerManager() { removeAll(); }
     30        ~LoggerManager() { removeAll(); }
    3131};
    3232
    33 extern THREAD_LOCAL_DECL(MessageHandlerManager, message_handler_manager_instance);
     33extern THREAD_LOCAL_DECL(LoggerManager, message_handler_manager_instance);
    3434
    3535////////////////////////////////////////
    3636
    37 class MessageHandlerBase
     37class LoggerBase
    3838{
    39         friend class MessageHandlerManager;
     39        friend class LoggerManager;
    4040protected:
    41         MessageHandlerManager* manager;
     41        LoggerManager* manager;
    4242        int options;
    4343
    4444public:
    4545
    46         enum HandlerOptions
     46        enum LoggerOptions
    4747        {
    4848                DontBlock = 1, CannotBeBlocked = 2, Enable = 4, Paused = 8
    4949        };
    5050
    51         void Hprintf(const char *o, const char *m, int w, const char *bl, ...);
    52         void send(const char *o, const char *m, const char *bl, int w);
     51        void logPrintf(const char *o, const char *m, int w, const char *bl, ...);
     52        void send(const char *o, const char *m, int w, const char *bl);
    5353
    5454        bool isEnabled() { return manager ? true : false; }
     
    5959        void resume();
    6060
    61         MessageHandlerBase(int opts = 0) :manager(NULL), options(opts)
     61        LoggerBase(int opts = 0) :manager(NULL), options(opts)
    6262        {
    6363                if (options&Enable) enable();
    6464        }
    65         virtual ~MessageHandlerBase()
     65        virtual ~LoggerBase()
    6666        {
    6767                disable();
    6868        }
    6969
    70         virtual void handle(const char *o, const char *m, const char *bl, int w) {}
     70        virtual void handle(const char *o, const char *m, int w, const char *bl) {}
    7171};
    7272
    7373///////////////////////////////////////////
    7474
    75 class MessageHandlerToMemory : public MessageHandlerBase
     75class LoggerToMemory : public LoggerBase
    7676{
    7777protected:
     
    8181public:
    8282
    83         void reset() { maxlevel = HMLV_INFO - 1; errcount = warncount = storedcount = infocount = 0; msgs = 0; }
     83        void reset() { maxlevel = LOG_INFO - 1; errcount = warncount = storedcount = infocount = 0; msgs = 0; }
    8484
    8585        enum Options2
     
    9595        const SString& getMessages() { return msgs; }
    9696
    97         MessageHandlerToMemory(int opts = 0, int minimal_level_to_store = HMLV_ERROR) :MessageHandlerBase(opts), minleveltostore(minimal_level_to_store)
     97        LoggerToMemory(int opts = 0, int minimal_level_to_store = LOG_ERROR) :LoggerBase(opts), minleveltostore(minimal_level_to_store)
    9898        {
    9999                reset();
    100100        }
    101101
    102         void handle(const char *o, const char *m, const char *bl, int w);
     102        void handle(const char *o, const char *m, int w, const char *bl);
    103103};
    104104
    105 class RedirectingMessageHandler : public MessageHandlerBase
     105class RedirectingLogger : public LoggerBase
    106106{
    107         MessageHandlerManager *other_manager;
     107        LoggerManager *other_manager;
    108108public:
    109         RedirectingMessageHandler(MessageHandlerManager *other_mgr,int opts=0)
    110                 :MessageHandlerBase(opts), other_manager(other_mgr) {}
     109        RedirectingLogger(LoggerManager *other_mgr,int opts=0)
     110                :LoggerBase(opts), other_manager(other_mgr) {}
    111111
    112         void handle(const char *o, const char *m, const char *bl, int w)
     112        void handle(const char *o, const char *m, int w, const char *bl)
    113113        {
    114                 other_manager->send(o, m, bl, w);
     114                other_manager->send(o, m, w, bl);
    115115        }
    116116};
Note: See TracChangeset for help on using the changeset viewer.