Commit 6647be62 authored by Sebastien Ponce's avatar Sebastien Ponce
Browse files

Support for C strings, TimeStamps and IP addresses in the new logging system

parent 58951ff8
......@@ -17,7 +17,7 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# @(#)$RCSfile: Imakefile,v $ $Revision: 1.83 $ $Release$ $Date: 2005/04/05 11:51:33 $ $Author: sponcec3 $
# @(#)$RCSfile: Imakefile,v $ $Revision: 1.84 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
#
# Make Castor libraries and executables
#
......@@ -109,9 +109,11 @@ STGLIB_SRCS = IAddressCInt.cpp \
client/BaseClient.cpp \
client/BasicResponseHandler.cpp \
client/VectorResponseHandler.cpp \
dlf/Dlf.cpp \
dlf/IPAddress.cpp \
dlf/Message.cpp \
dlf/Param.cpp \
dlf/Dlf.cpp \
dlf/TimeStamp.cpp \
io/AbstractSocket.cpp \
io/ClientSocket.cpp \
io/ServerSocket.cpp \
......
/******************************************************************************
* IPAddress.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: IPAddress.cpp,v $ $Revision: 1.1 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
*
* A simple object around an IP address
*
* @author Sebastien Ponce
*****************************************************************************/
// Include Files
#include "castor/dlf/IPAddress.hpp"
/******************************************************************************
* IPAddress.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: IPAddress.hpp,v $ $Revision: 1.1 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
*
* A simple object around an IP address
*
* @author Sebastien Ponce
*****************************************************************************/
#ifndef DLF_IPADDRESS_HPP
#define DLF_IPADDRESS_HPP 1
namespace castor {
namespace dlf {
/**
* A simple object around an IP address
*/
class IPAddress {
public:
/**
* Constructor
*/
IPAddress(int ip) : m_ip(ip) {};
/**
* Accessor
*/
int ip() { return m_ip; }
private:
/// the IP address, as an int
int m_ip;
};
} // end of namespace dlf
} // end of namespace castor
#endif // DLF_IPADDRESS_HPP
......@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: Param.cpp,v $ $Revision: 1.1 $ $Release$ $Date: 2005/04/05 11:51:33 $ $Author: sponcec3 $
* @(#)$RCSfile: Param.cpp,v $ $Revision: 1.2 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
*
*
*
......@@ -25,7 +25,9 @@
*****************************************************************************/
// Include Files
#include <time.h>
#include <sstream>
#include <iomanip>
#include "castor/dlf/Param.hpp"
#include "castor/ObjectSet.hpp"
#include "castor/IObject.hpp"
......@@ -43,3 +45,39 @@ castor::dlf::Param::Param(char* name,
value->print(s, "", set);
m_cParam.par.par_string = strdup(s.str().c_str());
}
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
castor::dlf::Param::Param(char* name,
castor::dlf::IPAddress value) :
m_deallocate(true) {
m_cParam.name = name;
m_cParam.type = DLF_MSG_PARAM_STR;
std::ostringstream s;
s << ((value.ip() & 0xFF000000) >> 24) << "."
<< ((value.ip() & 0x00FF0000) >> 16) << "."
<< ((value.ip() & 0x0000FF00) >> 8) << "."
<< ((value.ip() & 0x000000FF));
m_cParam.par.par_string = strdup(s.str().c_str());
}
// -----------------------------------------------------------------------
// Constructor
// -----------------------------------------------------------------------
castor::dlf::Param::Param(char* name,
castor::dlf::TimeStamp value) :
m_deallocate(true) {
m_cParam.name = name;
m_cParam.type = DLF_MSG_PARAM_STR;
struct tm tmstruc;
time_t time = value.time();
localtime_r (&time, &tmstruc);
std::ostringstream s;
s << std::setw(2) << tmstruc.tm_mon+1
<< "/" << tmstruc.tm_mday
<< " " << tmstruc.tm_hour
<< ":" << tmstruc.tm_min
<< ":" << tmstruc.tm_sec;
m_cParam.par.par_string = strdup(s.str().c_str());
}
......@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: Param.hpp,v $ $Revision: 1.1 $ $Release$ $Date: 2005/04/05 11:51:33 $ $Author: sponcec3 $
* @(#)$RCSfile: Param.hpp,v $ $Revision: 1.2 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
*
* A parameter for the DLF (Distributed Logging System)
*
......@@ -32,6 +32,8 @@
#include "dlf_struct.h"
#include "castor/IObject.hpp"
#include "castor/stager/TapeVid.hpp"
#include "castor/dlf/IPAddress.hpp"
#include "castor/dlf/TimeStamp.hpp"
namespace castor {
......@@ -47,6 +49,16 @@ namespace castor {
/**
* Constructor for strings
*/
Param(char* name, std::string value) :
m_deallocate(true) {
m_cParam.name = name;
m_cParam.type = DLF_MSG_PARAM_STR;
m_cParam.par.par_string = strdup(value.c_str());
};
/**
* Constructor for C strings
*/
Param(char* name, char* value) :
m_deallocate(false) {
m_cParam.name = name;
......@@ -114,6 +126,16 @@ namespace castor {
m_cParam.par.par_string = value.vid();
};
/**
* Constructor for IPAddress
*/
Param(char* name, castor::dlf::IPAddress value);
/**
* Constructor for TimeStamp
*/
Param(char* name, castor::dlf::TimeStamp value);
/**
* Constructor for objects
*/
......
/******************************************************************************
* TimeStamp.cpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: TimeStamp.cpp,v $ $Revision: 1.1 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
*
* A simple object around an IP address
*
* @author Sebastien Ponce
*****************************************************************************/
// Include Files
#include "castor/dlf/TimeStamp.hpp"
/******************************************************************************
* TimeStamp.hpp
*
* This file is part of the Castor project.
* See http://castor.web.cern.ch/castor
*
* Copyright (C) 2003 CERN
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
* @(#)$RCSfile: TimeStamp.hpp,v $ $Revision: 1.1 $ $Release$ $Date: 2005/04/05 13:36:36 $ $Author: sponcec3 $
*
* A simple object around a time stamp
*
* @author Sebastien Ponce
*****************************************************************************/
#ifndef DLF_TIMESTAMP_HPP
#define DLF_TIMESTAMP_HPP 1
// Include Files
#include <time.h>
namespace castor {
namespace dlf {
/**
* A simple object around a time stamp
*/
class TimeStamp {
public:
/**
* Constructor
*/
TimeStamp(time_t time) : m_time(time) {};
/**
* Accessor
*/
int time() { return m_time; }
private:
/// the IP address, as an int
int m_time;
};
} // end of namespace dlf
} // end of namespace castor
#endif // DLF_TIMESTAMP_HPP
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment