~vbursian/research-assistant/intervers

« back to all changes in this revision

Viewing changes to RANet/Log.h

  • Committer: Viktor Bursian
  • Date: 2013-06-06 15:10:08 UTC
  • Revision ID: vbursian@gmail.com-20130606151008-6641eh62f0lgx8jt
Tags: version_0.3.0
version 0.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
/*! @file Log.h   Собирает структурированную трассировочную информацию.
 
3
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
 
4
- Copyright(C) 2011, Viktor E. Bursian, St.Petersburg, Russia.
 
5
                     Viktor.Bursian@mail.ioffe.ru
 
6
*///////////////////////////////////////////////////////////////////////////////
 
7
#ifndef Log_H
 
8
#define Log_H
 
9
#include "Strings.h"
 
10
#include "Time.h"
 
11
#include <list>
 
12
#include <set>
 
13
namespace RA {
 
14
//------------------------------------------------------------------------------
 
15
 
 
16
ANNOUNCE_CLASS(sLog)
 
17
 
 
18
namespace RANet {
 
19
 
 
20
RANet_EXPORT extern  sLog                Log;
 
21
 
 
22
};
 
23
 
 
24
//---------------------------------------------------------------------- sLog---
 
25
/*! Собирает структурированную трассировочную информацию.
 
26
 
 
27
цикл с фильтром
 
28
вывод в поток
 
29
*/
 
30
class RANet_EXPORT  sLog
 
31
{
 
32
  public://types
 
33
    enum                          eSeverity {Debug
 
34
                                            ,Admin
 
35
                                            ,Info
 
36
                                            ,Warning
 
37
                                            ,Critical
 
38
                                            ,ProgramError
 
39
                                            ,Conditionless};
 
40
    ANNOUNCE_CLASS(sItem)
 
41
    class sItem //: public virtual sStorable
 
42
    {
 
43
      public:
 
44
        unsigned int              Level () const
 
45
                                    { return TheLevel; };
 
46
        psItem                    Parent () const
 
47
                                    { return TheParent; };
 
48
        sTime                     Time () const
 
49
                                    { return TheTime; };
 
50
        eSeverity                 Severity () const
 
51
                                    { return TheSeverity; };
 
52
        sString                   Topic () const
 
53
                                    { return TheTopic; };
 
54
        sString                   Message () const
 
55
                                    { return TheMessage; };
 
56
        sString                   Text () const;
 
57
 
 
58
      private:
 
59
                                  sItem (psItem     parent
 
60
                                        ,unsigned int  level
 
61
                                        ,eSeverity  severity
 
62
                                        ,sString    topic
 
63
                                        ,sString    message );
 
64
      private://fields
 
65
        sTime                     TheTime;
 
66
        eSeverity                 TheSeverity;
 
67
        sString                   TheTopic;
 
68
        sString                   TheMessage;
 
69
        unsigned int              TheLevel;
 
70
        psItem                    TheParent;
 
71
      friend class sLog;
 
72
    };
 
73
 
 
74
  public:
 
75
                              ~sLog ();
 
76
                              sLog ();
 
77
    void                      Put (eSeverity  severity
 
78
                                  ,sString    topic
 
79
                                  ,sString    message );
 
80
    void                      OpenBlock (eSeverity  severity
 
81
                                        ,sString    topic
 
82
                                        ,sString    message );
 
83
    void                      OpenBlock (eSeverity  severity
 
84
                                        ,sString    topic   );
 
85
    void                      CloseBlock (eSeverity  severity
 
86
                                         ,sString    topic);
 
87
    void                      SetShowSeverity (eSeverity  severity);
 
88
    void                      AlwaysHide (sString  topic);
 
89
    void                      AlwaysShow (sString  topic);
 
90
 
 
91
  private://fields
 
92
    std::list<psItem>         Items;
 
93
    psItem                    CurrentBlock;
 
94
    unsigned int              CurrentLevel;
 
95
    eSeverity                 TheShowSeverity;
 
96
    std::set<sString>         TopicsToHide;
 
97
    std::set<sString>         TopicsToShow;
 
98
};
 
99
 
 
100
//------------------------------------------------------------------------------
 
101
}; //namespace RA
 
102
#endif