DimAppender.cpp

Go to the documentation of this file.
00001 #include "DimAppender.h"
00002 
00003 //#include <logg4cpp/PortabilityImpl.hh>
00004 #ifdef LOG4CPP_HAVE_IO_H
00005 #    include <io.h>
00006 #endif
00007 #ifdef LOG4CPP_HAVE_UNISTD_H
00008 #    include <unistd.h>
00009 #endif
00010 
00011 #include <memory>
00012 #include <stdio.h>
00013 #include <time.h>
00014 #include <log4cpp/FileAppender.hh>
00015 #include <log4cpp/Category.hh>
00016 #include <log4cpp/FactoryParams.hh>
00017 
00018 
00019 namespace log4cpp {
00020 
00021         using namespace std;
00022         
00023         DimAppender::DimAppender(const std::string& name, const std::string& serviceName):LayoutAppender(name){
00024                 
00025                 
00026                 this->_dimLogChannel = new DimService(serviceName.c_str() ,  "started");
00027                 _serviceName = serviceName;
00028         }
00029         
00030         DimAppender::~DimAppender(){
00031                 //cout << "destructing dim appender " <<  this->getName().c_str()<< "\n";
00032                 close();
00033         }
00034 
00036         void DimAppender::_append(const LoggingEvent& event) {
00037                 
00038                                 // gets the string foramted from the mother class
00039                 _message = _getLayout().format(event);
00040                                 // updates the service, easy no?!
00041                                 // I am casting the pointer to the internal memory from const char * to char *
00042                                 // I hope that the dim thing does not do nasty stuff with that
00043                 if (_dimLogChannel!= NULL)_dimLogChannel->updateService((char *) _message.c_str());
00044                 
00045                 
00046         }
00047 
00048                 // closes the logging
00049         void DimAppender::close(void){
00050                 if (_dimLogChannel != NULL){
00051                         //cout << "closing dim appender " << this->getName().c_str() << "\n";
00052                         delete _dimLogChannel;
00053                         _dimLogChannel=NULL;
00054                         
00055                 }
00056         }
00057         
00058                 //reopens the dim connections
00059         bool DimAppender::reopen(){
00060                 
00061                 if (this->_dimLogChannel != NULL) return true;
00062                 
00063                 this->_dimLogChannel = new DimService(_serviceName.c_str() ,  "re-started");
00064                 return true;
00065         }
00066         
00073         std::auto_ptr<Appender> create_dim_appender(const FactoryParams& params)
00074         {
00075                 std::string name, serviceName;
00076         
00077                 params.get_for("dim appender").required("name", name)("service", serviceName);
00078                 
00079 
00080                 return std::auto_ptr<Appender>(new DimAppender(name, serviceName));
00081         }
00082 
00083         
00084 }

Generated on Sat Mar 29 22:55:54 2008 for pixelTrigger by  doxygen 1.5.0