LogService
libdadi: utility tools for distributed applications
LogComponentBase.hh
1 /****************************************************************************/
2 /* LogComponentBase header class */
3 /* */
4 /* Author(s): */
5 /* - Georg Hoesch (hoesch@in.tum.de) */
6 /* - Cyrille Pontvieux (cyrille.pontvieux@edu.univ-fcomte.fr) */
7 /* */
8 /* This file is part of DIET . */
9 /* */
10 /* Copyright (C) 2000-2003 ENS Lyon, LIFC, INSA, INRIA and SysFera (2000) */
11 /* */
12 /* - Frederic.Desprez@ens-lyon.fr (Project Manager) */
13 /* - Eddy.Caron@ens-lyon.fr (Technical Manager) */
14 /* - Tech@sysfera.com (Maintainer and Technical Support) */
15 /* */
16 /* This software is a computer program whose purpose is to provide an */
17 /* distributed logging services. */
18 /* */
19 /* */
20 /* This software is governed by the CeCILL license under French law and */
21 /* abiding by the rules of distribution of free software. You can use, */
22 /* modify and/ or redistribute the software under the terms of the CeCILL */
23 /* license as circulated by CEA, CNRS and INRIA at the following URL */
24 /* "http://www.cecill.info". */
25 /* */
26 /* As a counterpart to the access to the source code and rights to copy, */
27 /* modify and redistribute granted by the license, users are provided */
28 /* only with a limited warranty and the software's author, the holder */
29 /* of the economic rights, and the successive licensors have only */
30 /* limited liability. */
31 /* */
32 /* In this respect, the user's attention is drawn to the risks */
33 /* associated with loading, using, modifying and/or developing or */
34 /* reproducing the software by the user in light of its specific status */
35 /* of free software, that may mean that it is complicated to */
36 /* manipulate, and that also therefore means that it is reserved for */
37 /* developers and experienced professionals having in-depth computer */
38 /* knowledge. Users are therefore encouraged to load and test the */
39 /* software's suitability as regards their requirements in conditions */
40 /* enabling the security of their systems and/or data to be ensured and, */
41 /* more generally, to use and operate it in the same conditions as */
42 /* regards security. */
43 /* */
44 /* The fact that you are presently reading this means that you have had */
45 /* knowledge of the CeCILL license and that you accept its terms. */
46 /* */
47 /****************************************************************************/
48 /* $Id$
49  * $Log$
50  * Revision 1.5 2011/02/04 15:53:55 bdepardo
51  * Use a const char* name in constructor, then strdup the name.
52  * Then use free instead of delete on this->name
53  *
54  * Revision 1.4 2010/12/03 12:40:26 kcoulomb
55  * MAJ log to use forwarders
56  *
57  * Revision 1.3 2010/11/10 02:27:44 kcoulomb
58  * Update the log to use the forwarder.
59  * Programm run without launching forwarders but fails with forwarder.
60  *
61  * Revision 1.2 2007/08/31 16:41:17 bdepardo
62  * When trying to add a new component, we check if the name of the component exists and if the component is reachable
63  * - it the name already exists:
64  * - if the component is reachable, then we do not connect the new component
65  * - else we consider that the component is lost, and we delete the old component ant add the new one
66  * - else add the component
67  *
68  * Revision 1.1 2004/01/09 11:07:12 ghoesch
69  * Restructured the whole LogService source tree.
70  * Added autotools make process. Cleaned up code.
71  * Removed some testers. Ready to release.
72  *
73  ****************************************************************************/
74 
75 #ifndef _LOGCOMPONENTBASE_HH_
76 #define _LOGCOMPONENTBASE_HH_
77 
78 #include <omnithread.h>
79 
80 #include "LogTypes.hh"
81 #include "ComponentConfigurator_impl.hh"
82 #include "PingThread.hh"
83 #include "FlushBufferThread.hh"
84 #include "LogComponent.hh"
85 
86 #define PINGTHREAD_SLEEP_TIME_SEC 1
87 #define PINGTHREAD_SLEEP_TIME_NSEC 0
88 #define PINGTHREAD_SYNCHRO_FREQUENCY 60
89 #define FLUSHBUFFERTHREAD_SLEEP_TIME_SEC 0
90 #define FLUSHBUFFERTHREAD_SLEEP_TIME_NSEC 50000000
91 
92 class LogComponentBase;
93 
95 public:
96  LogComponentBase(bool* success, int argc, char** argv,
97  unsigned int tracelevel, const char* name,
98  unsigned int port = 0);
99 
100  ~LogComponentBase();
101 
102  void
103  setName(const char* name);
104 
105  char*
106  getName();
107 
108  char*
109  getHostname();
110 
111  short
112  connect(const char* message);
113 
114  short
115  disconnect(const char* message);
116 
117  void
118  sendMsg(const char* tag, const char* msg);
119 
120  bool
121  isLog(const char* tagname);
122 
123  LogCentralComponent_var LCCref;
124  ComponentConfigurator_var CCref;
125  log_msg_buf_t buffer;
126  tag_list_t currentTagList;
127 
128 private:
129  log_time_t
130  getLocalTime();
131 
132  char* name;
133  char* hostname;
135  PingThread* pingThread;
136  FlushBufferThread* flushBufferThread;
137 };
138 
139 #endif
140 
Definition: LogComponentBase.hh:94
Definition: FlushBufferThread.hh:75
Definition: libraries/LogComponentBaseC++/ComponentConfigurator_impl.hh:77
Definition: LogTypes.hh:57
Definition: LogTypes.hh:107
Definition: PingThread.hh:74
Definition: LogTypes.hh:221