[prev in list] [next in list] [prev in thread] [next in thread]
List: sptk-commits
Subject: r1043 - trunk/sptk4
From: alexey () mail ! total-knowledge ! com
Date: 2009-10-31 7:17:30
Message-ID: courier.000000004AEBE48A.00000995 () mail ! total-knowledge ! com
[Download RAW message or body]
Author: alexey
Date: 2009-10-31 00:17:29 -0700 (Sat, 31 Oct 2009)
New Revision: 1043
Added:
trunk/sptk4/CFileLogger.h
trunk/sptk4/CSysLogger.h
Removed:
trunk/sptk4/CFileLog.h
trunk/sptk4/CSysLog.h
Log:
Fixing race conditions ..
Deleted: trunk/sptk4/CFileLog.h
===================================================================
--- trunk/sptk4/CFileLog.h 2009-10-31 07:12:47 UTC (rev 1042)
+++ trunk/sptk4/CFileLog.h 2009-10-31 07:17:29 UTC (rev 1043)
@@ -1,95 +0,0 @@
-/***************************************************************************
- SIMPLY POWERFUL TOOLKIT (SPTK)
- CFileLog.h - description
- -------------------
- begin : Tue Jan 31 2006
- copyright : (C) 2001-2009 by Alexey Parshin. All rights reserved.
- email : alexeyp@gmail.com
-
- This module creation was sponsored by Total Knowledge \
(http://www.total-knowledge.com).
- Author thanks the developers of CPPSERV project \
(http://www.total-knowledge.com/progs/cppserv)
- for defining the requirements for this class.
- ***************************************************************************/
-
-/***************************************************************************
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the <ORGANIZATION> nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- ***************************************************************************/
-
-#ifndef __CFILELOG_H__
-#define __CFILELOG_H__
-
-#include <sptk4/CBaseLog.h>
-#include <fstream>
-
-namespace sptk {
-
-/// @addtogroup log Log Classes
-/// @{
-
-/// @brief A log stored in the regular file.
-///
-/// A simplest possible way to implement logging.
-/// The log file is created automatically if it doesn't exist.
-/// @see CBaseLog for more information about basic log abilities.
-class CFileLog : public CBaseLog {
- std::ofstream m_fileStream; ///< Log file stream
- std::string m_fileName; ///< Log file name
-protected:
-
-public:
- /// @brief Stores or sends log message to actual destination
- /// @param date CDateTime, message timestamp
- /// @param prefix const char*, message prefix
- /// @param message const char *, message text
- /// @param priority CLogPriority, message priority. @see CLogPriority for more \
information.
- virtual void saveMessage(CDateTime date,const char* prefix,const char \
*message,const CLogPriority *priority) throw(CException);
-
-public:
- /// @brief Constructor
- ///
- /// Creates a new log object based on the file name.
- /// If this file doesn't exist - it will be created.
- /// @param fileName string, log file name
- CFileLog(std::string fileName) : m_fileName(fileName) {}
-
- /// @brief Destructor
- ///
- /// Destructs the log object, closes the log file, releases all the allocated \
resources
- virtual ~CFileLog();
-
- /// @brief Restarts the log
- ///
- /// The current log content is cleared. The file is recreated.
- virtual void reset() throw(CException);
-
- /// @brief Returns log file name
- std::string fileName() const {
- return m_fileName;
- }
-};
-/// @}
-}
-
-#endif
Added: trunk/sptk4/CFileLogger.h
===================================================================
--- trunk/sptk4/CFileLogger.h (rev 0)
+++ trunk/sptk4/CFileLogger.h 2009-10-31 07:17:29 UTC (rev 1043)
@@ -0,0 +1,95 @@
+/***************************************************************************
+ SIMPLY POWERFUL TOOLKIT (SPTK)
+ CFileLogger.h - description
+ -------------------
+ begin : Tue Jan 31 2006
+ copyright : (C) 2001-2009 by Alexey Parshin. All rights reserved.
+ email : alexeyp@gmail.com
+
+ This module creation was sponsored by Total Knowledge \
(http://www.total-knowledge.com). + Author thanks the developers of CPPSERV \
project (http://www.total-knowledge.com/progs/cppserv) + for defining the \
requirements for this class. + \
***************************************************************************/ +
+/***************************************************************************
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the <ORGANIZATION> nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ***************************************************************************/
+
+#ifndef __CFILELOGGER_H__
+#define __CFILELOGGER_H__
+
+#include <sptk4/CBaseLog.h>
+#include <fstream>
+
+namespace sptk {
+
+/// @addtogroup log Log Classes
+/// @{
+
+/// @brief A log stored in the regular file.
+///
+/// A simplest possible way to implement logging.
+/// The log file is created automatically if it doesn't exist.
+/// @see CBaseLog for more information about basic log abilities.
+class CFileLogger : public CBaseLogger {
+ std::ofstream m_fileStream; ///< Log file stream
+ std::string m_fileName; ///< Log file name
+protected:
+
+public:
+ /// @brief Stores or sends log message to actual destination
+ /// @param date CDateTime, message timestamp
+ /// @param prefix const char*, message prefix
+ /// @param message const char *, message text
+ /// @param priority CLogPriority, message priority. @see CLogPriority for more \
information. + virtual void saveMessage(CDateTime date,const char* prefix,const \
char *message,const CLogPriority *priority) throw(CException); +
+public:
+ /// @brief Constructor
+ ///
+ /// Creates a new log object based on the file name.
+ /// If this file doesn't exist - it will be created.
+ /// @param fileName string, log file name
+ CFileLogger(std::string fileName) : m_fileName(fileName) {}
+
+ /// @brief Destructor
+ ///
+ /// Destructs the log object, closes the log file, releases all the allocated \
resources + virtual ~CFileLogger();
+
+ /// @brief Restarts the log
+ ///
+ /// The current log content is cleared. The file is recreated.
+ virtual void reset() throw(CException);
+
+ /// @brief Returns log file name
+ std::string fileName() const {
+ return m_fileName;
+ }
+};
+/// @}
+}
+
+#endif
Deleted: trunk/sptk4/CSysLog.h
===================================================================
--- trunk/sptk4/CSysLog.h 2009-10-31 07:12:47 UTC (rev 1042)
+++ trunk/sptk4/CSysLog.h 2009-10-31 07:17:29 UTC (rev 1043)
@@ -1,117 +0,0 @@
-/***************************************************************************
- SIMPLY POWERFUL TOOLKIT (SPTK)
- CSysLog.h - description
- -------------------
- begin : Tue Jan 31 2006
- copyright : (C) 2001-2009 by Alexey Parshin. All rights reserved.
- email : alexeyp@gmail.com
-
- This module creation was sponsored by Total Knowledge \
(http://www.total-knowledge.com).
- Author thanks the developers of CPPSERV project \
(http://www.total-knowledge.com/progs/cppserv)
- for defining the requirements for this class.
- ***************************************************************************/
-
-/***************************************************************************
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- * Neither the name of the <ORGANIZATION> nor the names of its contributors
- may be used to endorse or promote products derived from this software
- without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
- OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- ***************************************************************************/
-
-#ifndef __CSYSLOG_H__
-#define __CSYSLOG_H__
-
-#ifndef _WIN32
-#include <syslog.h>
-#else
-#include <winsock2.h>
-#include <windows.h>
-#endif
-
-#include <sptk4/CBaseLog.h>
-#include <string>
-
-namespace sptk {
-
-/// @addtogroup log Log Classes
-/// @{
-
-/// @brief A log stored in the system log.
-///
-/// On *nix , the log is sent to *nix syslog daemon.
-/// On Windows NT/2000+/XP the log is sent to Event Log (Application).
-/// On Windows 95/98/ME the system log isn't supported..
-/// The facility method allows to define - which system log is used
-/// @see CBaseLog for more information about basic log abilities.
-class CSysLog : public CBaseLog {
- static std::string m_programName; ///< The name of the program that is used as \
a prefix in the log
-#ifndef _WIN32
-
- static int m_objectCounter; ///< The counter of the log objects
- static bool m_logOpened; ///< (Unix) Is the log opened?
-#else
-
- HANDLE m_logHandle; ///< (Windows) The handle of the log file
- static std::string m_moduleFileName;///< (Windows) The file name of the module
- static bool m_registrySet; ///< (Windows) The flag indicates that \
registry key for that program name was created
-#endif
-
- /// List of facilities allows to define one or more system logs where messages \
would be sent
- uint32_t m_facilities;
-
- CWaiter m_lock; ///< Protection for the log operations
-
-public:
- /// @brief Stores or sends log message to actual destination
- ///
- /// This method should be overwritten by the actual log implementation
- /// @param date CDateTime, message timestamp
- /// @param prefix const char*, message prefix
- /// @param message const char *, message text
- /// @param priority CLogPriority, message priority. @see CLogPriority for more \
information.
- virtual void saveMessage(CDateTime date,const char* prefix,const char \
*message,const CLogPriority *priority) throw(CException);
-public:
- /// @brief Constructor
- ///
- /// Creates a new log object based on the syslog facility (or facilities).
- /// For Windows, parameter facilities is ignored and messages are stored
- /// into Application event log
- /// @param facilities int, log facility or a set of facilities.
- CSysLog(uint32_t facilities=LOG_USER);
-
- /// @brief Destructor
- ///
- /// Destructs the log object, closes the log descriptor, releases all the \
allocated resources
- virtual ~CSysLog();
-
- /// @brief Sets program name
- ///
- /// The program name is optional. It is set for all the CSysLog objects at once.
- /// If set, it appears in the log as a message prefix. Every time the program
- /// name is changed, the log is closed to be re-opened on next message.
- /// @param progName std::string, a program name
- static void programName(std::string progName);
-}
-;
-/// @}
-}
-#endif
Added: trunk/sptk4/CSysLogger.h
===================================================================
--- trunk/sptk4/CSysLogger.h (rev 0)
+++ trunk/sptk4/CSysLogger.h 2009-10-31 07:17:29 UTC (rev 1043)
@@ -0,0 +1,115 @@
+/***************************************************************************
+ SIMPLY POWERFUL TOOLKIT (SPTK)
+ CSysLogger.h - description
+ -------------------
+ begin : Tue Jan 31 2006
+ copyright : (C) 2001-2009 by Alexey Parshin. All rights reserved.
+ email : alexeyp@gmail.com
+
+ This module creation was sponsored by Total Knowledge \
(http://www.total-knowledge.com). + Author thanks the developers of CPPSERV \
project (http://www.total-knowledge.com/progs/cppserv) + for defining the \
requirements for this class. + \
***************************************************************************/ +
+/***************************************************************************
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+ * Neither the name of the <ORGANIZATION> nor the names of its contributors
+ may be used to endorse or promote products derived from this software
+ without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+ OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ***************************************************************************/
+
+#ifndef __CSYSLOGGER_H__
+#define __CSYSLOGGER_H__
+
+#ifndef _WIN32
+#include <syslog.h>
+#else
+#include <winsock2.h>
+#include <windows.h>
+#endif
+
+#include <sptk4/CBaseLog.h>
+#include <string>
+
+namespace sptk {
+
+/// @addtogroup log Log Classes
+/// @{
+
+/// @brief A log stored in the system log.
+///
+/// On *nix , the log is sent to *nix syslog daemon.
+/// On Windows NT/2000+/XP the log is sent to Event Log (Application).
+/// On Windows 95/98/ME the system log isn't supported..
+/// The facility method allows to define - which system log is used
+/// @see CBaseLog for more information about basic log abilities.
+class CSysLogger : public CBaseLogger {
+ static std::string m_programName; ///< The name of the program that is used as \
a prefix in the log +#ifndef _WIN32
+ static int m_objectCounter; ///< The counter of the log objects
+ static bool m_logOpened; ///< (Unix) Is the log opened?
+#else
+ HANDLE m_logHandle; ///< (Windows) The handle of the log file
+ static std::string m_moduleFileName;///< (Windows) The file name of the module
+ static bool m_registrySet; ///< (Windows) The flag indicates that \
registry key for that program name was created +#endif
+
+ /// List of facilities allows to define one or more system logs where messages \
would be sent + uint32_t m_facilities;
+
+ CWaiter m_lock; ///< Protection for the log operations
+
+public:
+ /// @brief Stores or sends log message to actual destination
+ ///
+ /// This method should be overwritten by the actual log implementation
+ /// @param date CDateTime, message timestamp
+ /// @param prefix const char*, message prefix
+ /// @param message const char *, message text
+ /// @param priority CLogPriority, message priority. @see CLogPriority for more \
information. + virtual void saveMessage(CDateTime date, const char* prefix, const \
char *message, const CLogPriority *priority) throw(CException); +public:
+ /// @brief Constructor
+ ///
+ /// Creates a new log object based on the syslog facility (or facilities).
+ /// For Windows, parameter facilities is ignored and messages are stored
+ /// into Application event log
+ /// @param facilities int, log facility or a set of facilities.
+ CSysLogger(uint32_t facilities = LOG_USER);
+
+ /// @brief Destructor
+ ///
+ /// Destructs the log object, closes the log descriptor, releases all the \
allocated resources + virtual ~CSysLogger();
+
+ /// @brief Sets program name
+ ///
+ /// The program name is optional. It is set for all the CSysLogger objects at \
once. + /// If set, it appears in the log as a message prefix. Every time the \
program + /// name is changed, the log is closed to be re-opened on next message.
+ /// @param progName std::string, a program name
+ static void programName(std::string progName);
+}
+;
+/// @}
+}
+#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic