LogService
libdadi: utility tools for distributed applications
 All Classes Functions Variables
LogComponentBase.hh
00001 /****************************************************************************/
00002 /* LogComponentBase header class                                            */
00003 /*                                                                          */
00004 /*  Author(s):                                                              */
00005 /*    - Georg Hoesch (hoesch@in.tum.de)                                     */
00006 /*    - Cyrille Pontvieux (cyrille.pontvieux@edu.univ-fcomte.fr)            */
00007 /*                                                                          */
00008 /*  This file is part of DIET .                                             */
00009 /*                                                                          */
00010 /*  Copyright (C) 2000-2003 ENS Lyon, LIFC, INSA, INRIA and SysFera (2000)  */
00011 /*                                                                          */
00012 /*  - Frederic.Desprez@ens-lyon.fr (Project Manager)                        */
00013 /*  - Eddy.Caron@ens-lyon.fr (Technical Manager)                            */
00014 /*  - Tech@sysfera.com (Maintainer and Technical Support)                   */
00015 /*                                                                          */
00016 /*  This software is a computer program whose purpose is to provide an      */
00017 /*  distributed logging services.                                           */
00018 /*                                                                          */
00019 /*                                                                          */
00020 /*  This software is governed by the CeCILL license under French law and    */
00021 /*  abiding by the rules of distribution of free software.  You can  use,   */
00022 /*  modify and/ or redistribute the software under the terms of the CeCILL  */
00023 /*  license as circulated by CEA, CNRS and INRIA at the following URL       */
00024 /*  "http://www.cecill.info".                                               */
00025 /*                                                                          */
00026 /*  As a counterpart to the access to the source code and  rights to copy,  */
00027 /*  modify and redistribute granted by the license, users are provided      */
00028 /*  only with a limited warranty  and the software's author,  the holder    */
00029 /*  of the economic rights,  and the successive licensors  have only        */
00030 /*  limited liability.                                                      */
00031 /*                                                                          */
00032 /*  In this respect, the user's attention is drawn to the risks             */
00033 /*  associated with loading,  using,  modifying and/or developing or        */
00034 /*  reproducing the software by the user in light of its specific status    */
00035 /*  of free software, that may mean  that it is complicated to              */
00036 /*  manipulate, and  that  also therefore means  that it is reserved for    */
00037 /*  developers and experienced professionals having in-depth computer       */
00038 /*  knowledge. Users are therefore encouraged to load and test the          */
00039 /*  software's suitability as regards their requirements in conditions      */
00040 /*  enabling the security of their systems and/or data to be ensured and,   */
00041 /*  more generally, to use and operate it in the same conditions as         */
00042 /*  regards security.                                                       */
00043 /*                                                                          */
00044 /*  The fact that you are presently reading this means that you have had    */
00045 /*  knowledge of the CeCILL license and that you accept its terms.          */
00046 /*                                                                          */
00047 /****************************************************************************/
00048 /* $Id$
00049  * $Log$
00050  * Revision 1.5  2011/02/04 15:53:55  bdepardo
00051  * Use a const char* name in constructor, then strdup the name.
00052  * Then use free instead of delete on this->name
00053  *
00054  * Revision 1.4  2010/12/03 12:40:26  kcoulomb
00055  * MAJ log to use forwarders
00056  *
00057  * Revision 1.3  2010/11/10 02:27:44  kcoulomb
00058  * Update the log to use the forwarder.
00059  * Programm run without launching forwarders but fails with forwarder.
00060  *
00061  * Revision 1.2  2007/08/31 16:41:17  bdepardo
00062  * When trying to add a new component, we check if the name of the component exists and if the component is reachable
00063  * - it the name already exists:
00064  *    - if the component is reachable, then we do not connect the new component
00065  *    - else we consider that the component is lost, and we delete the old component ant add the new one
00066  * - else add the component
00067  *
00068  * Revision 1.1  2004/01/09 11:07:12  ghoesch
00069  * Restructured the whole LogService source tree.
00070  * Added autotools make process. Cleaned up code.
00071  * Removed some testers. Ready to release.
00072  *
00073  ****************************************************************************/
00074 
00075 #ifndef _LOGCOMPONENTBASE_HH_
00076 #define _LOGCOMPONENTBASE_HH_
00077 
00078 #include <omnithread.h>
00079 
00080 #include "LogTypes.hh"
00081 #include "ComponentConfigurator_impl.hh"
00082 #include "PingThread.hh"
00083 #include "FlushBufferThread.hh"
00084 #include "LogComponent.hh"
00085 
00086 #define PINGTHREAD_SLEEP_TIME_SEC          1
00087 #define PINGTHREAD_SLEEP_TIME_NSEC         0
00088 #define PINGTHREAD_SYNCHRO_FREQUENCY       60
00089 #define FLUSHBUFFERTHREAD_SLEEP_TIME_SEC   0
00090 #define FLUSHBUFFERTHREAD_SLEEP_TIME_NSEC  50000000
00091 
00092 class LogComponentBase;
00093 
00094 class LogComponentBase {
00095 public:
00096   LogComponentBase(bool* success, int argc, char** argv,
00097                    unsigned int tracelevel, const char* name,
00098                    unsigned int port = 0);
00099 
00100   ~LogComponentBase();
00101 
00102   void
00103   setName(const char* name);
00104 
00105   char*
00106   getName();
00107 
00108   char*
00109   getHostname();
00110 
00111   short
00112   connect(const char* message);
00113 
00114   short
00115   disconnect(const char* message);
00116 
00117   void
00118   sendMsg(const char* tag, const char* msg);
00119 
00120   bool
00121   isLog(const char* tagname);
00122 
00123   LogCentralComponent_var LCCref;
00124   ComponentConfigurator_var CCref;
00125   log_msg_buf_t buffer;
00126   tag_list_t currentTagList;
00127 
00128 private:
00129   log_time_t
00130   getLocalTime();
00131 
00132   char* name;
00133   char* hostname;
00134   ComponentConfigurator_impl* CCimpl;
00135   PingThread* pingThread;
00136   FlushBufferThread* flushBufferThread;
00137 };
00138 
00139 #endif
00140