[asterisk-scf-commits] asterisk-scf/release/logger.git branch "master" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Fri Dec 30 14:52:45 CST 2011
branch "master" has been updated
via b1fbf637ca4be926ec6bc2f83259510cbaa3fc77 (commit)
via 4847d6bb166929bcd8a61298e163c7c32c3b60c8 (commit)
via 84105007123b7da69d1beb193e6faa59769e17f4 (commit)
via 92c15ef34568c4e5ea176d6209d21e52b026dadb (commit)
from 87254bbfef0d69634d732b383ab46c0521d22791 (commit)
Summary of changes:
client/src/CMakeLists.txt | 40 +++++++++++-----------
client/src/IceConfigurator.h | 2 +-
client/src/LogFormatter.cpp | 2 +-
client/src/Logger.cpp | 2 +-
client/src/LoggerFactory.cpp | 2 +-
client/src/OstreamLogger.cpp | 2 +-
client/test/CMakeLists.txt | 34 ++++++++++----------
client/test/ExpectedLogOut.h | 2 +-
client/test/LogBuf-test.cpp | 2 +-
client/test/Logger-test.cpp | 2 +-
client/test/LoggerFactory-test.cpp | 2 +-
client/test/{scf-log.cpp => SCFLog.cpp} | 2 +-
include/AsteriskSCF/{logger.h => Logger.h} | 0
server/src/CMakeLists.txt | 48 ++++++++++++++--------------
server/src/{main.cpp => Component.cpp} | 0
server/test/CMakeLists.txt | 18 +++++-----
server/test/ConfigurationTest.cpp | 2 +-
17 files changed, 81 insertions(+), 81 deletions(-)
rename client/test/{scf-log.cpp => SCFLog.cpp} (99%)
rename include/AsteriskSCF/{logger.h => Logger.h} (100%)
rename server/src/{main.cpp => Component.cpp} (100%)
- Log -----------------------------------------------------------------
commit b1fbf637ca4be926ec6bc2f83259510cbaa3fc77
Merge: 4847d6b 87254bb
Author: Mark Michelson <mmichelson at digium.com>
Date: Fri Dec 30 14:54:12 2011 -0600
Merge branch 'master' of git.asterisk.org:asterisk-scf/release/logger
commit 4847d6bb166929bcd8a61298e163c7c32c3b60c8
Author: Mark Michelson <mmichelson at digium.com>
Date: Tue Dec 27 16:21:01 2011 -0600
logger.h -> Logger.h
logging-client -> LoggingClient
logging-service-lib -> LoggingServiceLib
diff --git a/client/test/CMakeLists.txt b/client/test/CMakeLists.txt
index 894d7d0..7d682e9 100644
--- a/client/test/CMakeLists.txt
+++ b/client/test/CMakeLists.txt
@@ -1,20 +1,20 @@
include_directories(../src)
-astscf_component_init(logging-client-test)
-astscf_component_add_files(logging-client-test Logger-test.cpp)
-astscf_component_add_files(logging-client-test LoggerFactory-test.cpp)
-astscf_component_add_files(logging-client-test LogBuf-test.cpp)
-astscf_component_add_files(logging-client-test IceConfigurator-test.cpp)
-astscf_component_add_files(logging-client-test client-test.cpp)
-astscf_component_add_files(logging-client-test ExpectedLogOut.h)
-astscf_component_add_boost_libraries(logging-client-test unit_test_framework)
-astscf_component_add_slice_collection_libraries(logging-client-test ASTSCF)
-astscf_component_build_standalone(logging-client-test)
-target_link_libraries(logging-client-test logging-client)
-astscf_test_boost(logging-client-test)
+astscf_component_init(LoggingClientTest)
+astscf_component_add_files(LoggingClientTest Logger-test.cpp)
+astscf_component_add_files(LoggingClientTest LoggerFactory-test.cpp)
+astscf_component_add_files(LoggingClientTest LogBuf-test.cpp)
+astscf_component_add_files(LoggingClientTest IceConfigurator-test.cpp)
+astscf_component_add_files(LoggingClientTest client-test.cpp)
+astscf_component_add_files(LoggingClientTest ExpectedLogOut.h)
+astscf_component_add_boost_libraries(LoggingClientTest unit_test_framework)
+astscf_component_add_slice_collection_libraries(LoggingClientTest ASTSCF)
+astscf_component_build_standalone(LoggingClientTest)
+target_link_libraries(LoggingClientTest LoggingClient)
+astscf_test_boost(LoggingClientTest)
-astscf_component_init(scf-log)
-astscf_component_add_files(scf-log scf-log.cpp)
-astscf_component_add_boost_libraries(scf-log program_options)
-astscf_component_build_standalone(scf-log)
-target_link_libraries(scf-log logging-client)
+astscf_component_init(SCFLog)
+astscf_component_add_files(SCFLog SCFLog.cpp)
+astscf_component_add_boost_libraries(SCFLog program_options)
+astscf_component_build_standalone(SCFLog)
+target_link_libraries(SCFLog LoggingClient)
diff --git a/client/test/ExpectedLogOut.h b/client/test/ExpectedLogOut.h
index 78ef6f9..9ef96ac 100644
--- a/client/test/ExpectedLogOut.h
+++ b/client/test/ExpectedLogOut.h
@@ -10,7 +10,7 @@
#include <boost/test/unit_test.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
namespace AsteriskSCF
{
diff --git a/client/test/LogBuf-test.cpp b/client/test/LogBuf-test.cpp
index fbdbc60..6ca7fa4 100644
--- a/client/test/LogBuf-test.cpp
+++ b/client/test/LogBuf-test.cpp
@@ -17,7 +17,7 @@
#include <boost/test/unit_test.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
#include "ExpectedLogOut.h"
using namespace AsteriskSCF::System::Logging;
diff --git a/client/test/Logger-test.cpp b/client/test/Logger-test.cpp
index 380a399..18c48d9 100644
--- a/client/test/Logger-test.cpp
+++ b/client/test/Logger-test.cpp
@@ -21,7 +21,7 @@
#include <boost/test/unit_test.hpp>
#include <boost/asio/ip/host_name.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
#include "ExpectedLogOut.h"
using namespace std;
diff --git a/client/test/LoggerFactory-test.cpp b/client/test/LoggerFactory-test.cpp
index 1eebc8c..d2a6017 100644
--- a/client/test/LoggerFactory-test.cpp
+++ b/client/test/LoggerFactory-test.cpp
@@ -16,7 +16,7 @@
#include <boost/test/unit_test.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
#include "ExpectedLogOut.h"
using namespace AsteriskSCF::System::Logging;
diff --git a/client/test/scf-log.cpp b/client/test/SCFLog.cpp
similarity index 99%
rename from client/test/scf-log.cpp
rename to client/test/SCFLog.cpp
index c7bdf64..c5ac0a8 100644
--- a/client/test/scf-log.cpp
+++ b/client/test/SCFLog.cpp
@@ -23,7 +23,7 @@
#include <boost/program_options/parsers.hpp>
#include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
using namespace AsteriskSCF::System::Logging;
namespace po = boost::program_options;
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index ee98fd3..c585eb1 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -1,13 +1,13 @@
include_directories(../src)
-astscf_component_init(logging-service-test)
-astscf_component_add_files(logging-service-test LoggingServer-test.cpp)
-astscf_component_add_files(logging-service-test server-test.cpp)
-astscf_component_add_boost_libraries(logging-service-test unit_test_framework)
-astscf_component_add_slice_collection_libraries(logging-service-test ASTSCF)
-astscf_component_build_standalone(logging-service-test)
-target_link_libraries(logging-service-test logging-service-lib)
-astscf_test_boost(logging-service-test)
+astscf_component_init(LoggingServiceTest)
+astscf_component_add_files(LoggingServiceTest LoggingServer-test.cpp)
+astscf_component_add_files(LoggingServiceTest server-test.cpp)
+astscf_component_add_boost_libraries(LoggingServiceTest unit_test_framework)
+astscf_component_add_slice_collection_libraries(LoggingServiceTest ASTSCF)
+astscf_component_build_standalone(LoggingServiceTest)
+target_link_libraries(LoggingServiceTest LoggingServiceLib)
+astscf_test_boost(LoggingServiceTest)
astscf_component_init(LoggingConfigurationTest)
astscf_component_add_files(LoggingConfigurationTest ConfigurationTest.cpp)
@@ -17,5 +17,5 @@ astscf_component_add_slices(LoggingConfigurationTest PROJECT AsteriskSCF/Configu
astscf_component_add_boost_libraries(LoggingConfigurationTest unit_test_framework system)
astscf_component_add_slice_collection_libraries(LoggingConfigurationTest ASTSCF)
astscf_component_build_icebox(LoggingConfigurationTest)
-target_link_libraries(LoggingConfigurationTest astscf-api logging-service-lib logging-client)
+target_link_libraries(LoggingConfigurationTest astscf-api LoggingServiceLib LoggingClient)
astscf_test_icebox(LoggingConfigurationTest server/config/testloggingserver.conf)
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index 9b3d0eb..053b6bb 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -29,7 +29,7 @@
#include <AsteriskSCF/System/Component/ConfigurationIf.h>
#include <AsteriskSCF/Logger/IceLogger.h>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
#include "LoggingConfigurationHelper.h"
commit 84105007123b7da69d1beb193e6faa59769e17f4
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Dec 1 10:53:06 2011 -0600
I apparently didn't do a git mv on the logger.h file and instead did a regular mv.
This adds the new Logger.h file.
diff --git a/include/AsteriskSCF/Logger.h b/include/AsteriskSCF/Logger.h
new file mode 100644
index 0000000..158cdd4
--- /dev/null
+++ b/include/AsteriskSCF/Logger.h
@@ -0,0 +1,502 @@
+/*
+ * Asterisk SCF -- An open-source communications framework.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk SCF project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE.txt file
+ * at the top of the source tree.
+ */
+
+#pragma once
+
+#include <ostream>
+#include <cstdarg>
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/thread/locks.hpp>
+#include <boost/thread/mutex.hpp>
+#include <boost/thread/shared_mutex.hpp>
+#include <boost/weak_ptr.hpp>
+#include <boost/lexical_cast.hpp>
+
+#include <AsteriskSCF/System/Logger/LoggerIf.h>
+#include <AsteriskSCF/Logger/Level.h>
+#include <AsteriskSCF/Logger/LogOut.h>
+#include <AsteriskSCF/Logger/LogConsts.h>
+#include <AsteriskSCF/Logger/LogFormatter.h>
+
+namespace AsteriskSCF
+{
+namespace System
+{
+namespace Logging
+{
+
+/**
+ * A streambuf for writing to a LogOut. Messages are written at newlines (\n)
+ * or when destroyed. The way temporary object lifecycles work in C++, this is
+ * very convenient.
+ */
+class ASTSCF_DLL_EXPORT LogBuf : public std::streambuf
+{
+public:
+ LogBuf(LogOut& out, const std::string& name, Level logLevel);
+
+ /**
+ * Copy ctor.
+ * @param orig Original.
+ */
+ LogBuf(const LogBuf& orig);
+
+ ~LogBuf();
+
+
+ /**
+ * Assignment probably never gets used, but just in case.
+ */
+ LogBuf& operator=(const LogBuf& orig);
+
+protected:
+ int overflow(int c);
+
+private:
+ std::stringbuf mBuffer;
+ LogOut& mOut;
+ std::string mName;
+ Level mLogLevel;
+
+ /**
+ * Sends the current buffer to the formatter and clears it.
+ */
+ void sendBuffer();
+};
+
+/**
+ * A ostream-like thing which will only process output if enabled. When
+ * disabled, it very efficiently ignores operator<<() calls.
+ */
+class CondStream
+{
+public:
+ CondStream(LogOut& out, const std::string& name, Level level,
+ bool enabled) :
+ mBuf(out,name,level), mStream(&mBuf), mEnabled(enabled)
+ {
+ }
+
+ /**
+ * Copy ctor.
+ * @param orig Original.
+ */
+ CondStream(const CondStream& orig) :
+ mBuf(orig.mBuf), mStream(&mBuf), mEnabled(orig.mEnabled)
+ {
+
+ }
+
+ /**
+ * Output operator. Only does something when enabled == true.
+ * @param val Value to output.
+ * @return this.
+ */
+ template<typename T>
+ CondStream& operator<<(const T& val);
+
+ /**
+ * Output operator for manipulators, such as endl.
+ */
+ CondStream& operator<<(std::ostream& (*pf)(std::ostream&));
+
+private:
+ /**
+ * streambuffer for writing characters.
+ */
+ LogBuf mBuf;
+ /**
+ * Ostream for processing output.
+ */
+ std::ostream mStream;
+ /**
+ * If false, operator<<() does nothing.
+ */
+ bool mEnabled;
+};
+
+template<typename T>
+inline CondStream& CondStream::operator<<(const T& val)
+{
+ if (mEnabled)
+ {
+ mStream << val;
+ }
+ return *this;
+}
+
+inline CondStream& CondStream::operator<<(std::ostream& (*pf)(std::ostream&))
+{
+ if (mEnabled)
+ {
+ mStream << pf;
+ }
+ return *this;
+}
+
+/**
+ * The Logger for a particular source, identified by the given name. This is a
+ * small wrapper class, which should be passed around by copy.
+ */
+class Logger
+{
+ // You may wonder why have this class at all. It only delegates to
+ // LoggerImpl, so why not typedef shared_ptr<LoggerImpl> LoggerPtr
+ // and use that? The problem with that approach is that we would lose
+ // the stream style debugging, or at least may it a bit more cumbersome.
+ // (*lg)(Debug) << "you'd have to dereference the smart pointer"
+ // lg->stream(Debug) << "or have a named function"
+private:
+ /** Implementation class */
+ class LoggerImpl;
+public:
+ /** Construct a Logger for an existing implementation */
+ Logger(const boost::shared_ptr<LoggerImpl>& impl);
+
+ /**
+ * Construct a root Logger.
+ */
+ Logger(const std::string& name, LogOut& out, Level logLevel = Debug);
+ /**
+ * If true, this Logger would log messages of the given Level.
+ *
+ * @param level Level to check.
+ * @return true if enabled for given level.
+ */
+ bool isEnabledFor(Level level) const;
+ /**
+ * Ostream style logging.
+ *
+ * @param level Level for messages sent to this stream.
+ * @return LogStream that logs at the given level.
+ */
+ CondStream operator()(Level level) const;
+ /**
+ * Log a single message.
+ */
+ void logs(Level level, const std::string& message);
+ /**
+ * Log a single printf-formatted message.
+ */
+#ifdef __GNUC__
+ __attribute__((format(printf, 3, 4)))
+#endif
+ void logf(Level level, char const *fmt, ...);
+ /**
+ * Log a single vprintf-formatted message.
+ */
+#ifdef __GNUC__
+ __attribute__((format(printf, 3, 0)))
+#endif
+ void vlogf(Level level, char const *fmt, va_list ap);
+ Logger getChild(const std::string& childName);
+ std::vector<Logger> getChildren() const;
+ const std::string& getName() const;
+ LogOut& getOutput() const;
+ void setOutput(LogOut& out);
+ /**
+ * Sets the current logLevel. Until unsetLevel() is called, we are no
+ * longer affected by changes to our parent's log level.
+ */
+ void setLevel(Level logLevel);
+ /**
+ * Changes our logLevel to now inherit from our parent.
+ */
+ void unsetLevel();
+ /**
+ * Returns the effective level of this Logger.
+ */
+ Level getEffectiveLevel() const;
+private:
+ boost::shared_ptr<LoggerImpl> mImpl;
+};
+
+
+class Logger::LoggerImpl
+{
+public:
+ /**
+ * Construct a root Logger.
+ */
+ ASTSCF_DLL_EXPORT LoggerImpl(const std::string& name, LogOut& out,
+ Level logLevel = Debug);
+ /**
+ * Construct a child Logger.
+ */
+ ASTSCF_DLL_EXPORT LoggerImpl(
+ const boost::shared_ptr<LoggerImpl>& parent, const std::string& name);
+
+ ASTSCF_DLL_EXPORT ~LoggerImpl();
+
+ /**
+ * If true, this Logger would log messages of the given Level.
+ *
+ * @param level Level to check.
+ * @return true if enabled for given level.
+ */
+ bool isEnabledFor(Level level) const
+ {
+ return level >= getEffectiveLevel();
+ }
+ /**
+ * Ostream style logging.
+ *
+ * @param level Level for messages sent to this stream.
+ * @return LogStream that logs at the given level.
+ */
+ ASTSCF_DLL_EXPORT CondStream operator()(Level level) const;
+
+ /**
+ * Log a single message.
+ */
+ ASTSCF_DLL_EXPORT void logs(Level level, const std::string& message) const;
+
+ /**
+ * Log a single vprintf-formatted message.
+ */
+#ifdef __GNUC__
+ __attribute__((format(printf, 3, 0)))
+#endif
+ ASTSCF_DLL_EXPORT void vlogf(Level level, char const *fmt, va_list ap) const;
+
+ ASTSCF_DLL_EXPORT Logger getChild(
+ const boost::shared_ptr<LoggerImpl>& self, const std::string& childName);
+ ASTSCF_DLL_EXPORT std::vector<Logger> getChildren() const;
+
+ const std::string& getName() const
+ {
+ return mName;
+ }
+
+ LogOut& getOutput() const
+ {
+ return *mOut;
+ }
+
+ ASTSCF_DLL_EXPORT void setOutput(LogOut& out);
+
+ /**
+ * Sets the current logLevel. Until unsetLevel() is called, we are no
+ * longer affected by changes to our parent's log level.
+ */
+ ASTSCF_DLL_EXPORT void setLevel(Level logLevel);
+
+ /**
+ * Changes our logLevel to now inherit from out parent.
+ */
+ ASTSCF_DLL_EXPORT void unsetLevel();
+
+ /**
+ * Returns the effective level of this Logger.
+ */
+ ASTSCF_DLL_EXPORT Level getEffectiveLevel() const;
+
+private:
+ // non-copyable
+ LoggerImpl(const Logger&);
+ const LoggerImpl& operator=(const LoggerImpl&);
+
+ /**
+ * Mutex for access to the children field.
+ */
+ mutable boost::mutex mChildrenMutex;
+
+ /**
+ * Parent pointer. We cannot change which parent we have, nor can we change
+ * our parent.
+ *
+ * This can't be a shared_ptr, because then the circular reference would
+ * cause memory leaks.
+ *
+ * It also can't be a raw pointer, since children can outlive their parents.
+ */
+ boost::weak_ptr<LoggerImpl const> const mParent;
+ typedef std::map<std::string, boost::shared_ptr<LoggerImpl> > Children;
+ /**
+ * Map of children. The key is the next final node in that child's name.
+ */
+ Children mChildren;
+ /**
+ * Name of this logger, in dotted-notation.
+ */
+ const std::string mName;
+ /**
+ * Output for log messages.
+ */
+ LogOut *mOut;
+ /**
+ * Mutex for accessing mLogLevel and mInherited. It's a shared_mutex
+ * to reduce read contention on the mutex.
+ */
+ mutable boost::shared_mutex mInheritedMutex;
+ /**
+ * Current level of this Logger. Only applicable if inheritedLevel == false.
+ */
+ Level mLogLevel;
+ /**
+ * If true, then our effectiveLevel == parent->effectiveLevel
+ */
+ bool mInheritedLevel;
+};
+
+
+// since these are all simple delegates to LoggerImpl, inline them
+
+inline Logger::Logger(const boost::shared_ptr<LoggerImpl>& impl) :
+ mImpl(impl)
+{
+}
+
+
+inline Logger::Logger(const std::string& name, LogOut& out, Level logLevel) :
+ mImpl(new LoggerImpl(name, out, logLevel))
+{
+}
+
+
+inline bool Logger::isEnabledFor(Level level) const
+{
+ return mImpl->isEnabledFor(level);
+}
+
+
+inline CondStream Logger::operator()(Level level) const
+{
+ return (*mImpl)(level);
+}
+
+
+inline void Logger::logs(Level level, const std::string& message)
+{
+ mImpl->logs(level, message);
+}
+
+
+inline void Logger::logf(Level level, char const *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+ try
+ {
+ mImpl->vlogf(level, fmt, ap);
+ }
+ catch(...)
+ {
+ va_end(ap);
+ throw;
+ }
+ va_end(ap);
+}
+
+
+inline void Logger::vlogf(Level level, char const *fmt, va_list ap)
+{
+ mImpl->vlogf(level, fmt, ap);
+}
+
+
+inline Logger Logger::getChild(const std::string& childName)
+{
+ return mImpl->getChild(mImpl, childName);
+}
+
+
+inline std::vector<Logger> Logger::getChildren() const
+{
+ return mImpl->getChildren();
+}
+
+
+inline const std::string& Logger::getName() const
+{
+ return mImpl->getName();
+}
+
+
+inline LogOut& Logger::getOutput() const
+{
+ return mImpl->getOutput();
+}
+
+
+inline void Logger::setOutput(LogOut& out)
+{
+ mImpl->setOutput(out);
+}
+
+
+inline void Logger::setLevel(Level logLevel)
+{
+ mImpl->setLevel(logLevel);
+}
+
+
+inline void Logger::unsetLevel()
+{
+ mImpl->unsetLevel();
+}
+
+
+inline Level Logger::getEffectiveLevel() const
+{
+ return mImpl->getEffectiveLevel();
+}
+
+
+/**
+ * Main entry point into the Logger system.
+ */
+class LoggerFactory
+{
+public:
+ ASTSCF_DLL_EXPORT LoggerFactory(LogOut& out);
+
+ /**
+ * Will get the Logger with the given name. If the Logger does not exist,
+ * it will be created.
+ *
+ * @param name Name of the Logger to be retrieved.
+ * @return Ref to the Logger.
+ * @thread-safe
+ */
+ ASTSCF_DLL_EXPORT Logger getLogger(const std::string& name);
+
+ /**
+ * Returns a vector of the names of all currently configured Logger's.
+ * @return Vector of Logger names.
+ */
+ ASTSCF_DLL_EXPORT std::vector<std::string> getLoggerNames() const;
+
+ ASTSCF_DLL_EXPORT void setLogOutput(LogOut& out);
+
+private:
+ Logger mRoot;
+
+ static void accumulateLoggerNames(Logger logger, std::vector<std::string>& out);
+};
+
+ASTSCF_DLL_EXPORT boost::shared_ptr<LogOut> buildOstreamLogger(std::ostream& out, const std::string& FmtStr = DefaultLogFormat);
+
+/**
+ * Returns the default configured LoggerFactory.
+ */
+ASTSCF_DLL_EXPORT LoggerFactory& getLoggerFactory();
+
+} // Logging
+} // System
+} // AsteriskSCF
commit 92c15ef34568c4e5ea176d6209d21e52b026dadb
Author: Mark Michelson <mmichelson at digium.com>
Date: Thu Dec 1 10:51:15 2011 -0600
Rename files to jibe with new standards.
diff --git a/client/src/CMakeLists.txt b/client/src/CMakeLists.txt
index fe5faab..9985d56 100644
--- a/client/src/CMakeLists.txt
+++ b/client/src/CMakeLists.txt
@@ -1,20 +1,20 @@
-astscf_component_init(logging-client)
-astscf_component_add_files(logging-client Logger.cpp)
-astscf_component_add_files(logging-client LoggerFactory.cpp)
-astscf_component_add_files(logging-client LogOut.cpp)
-astscf_component_add_files(logging-client LogFormatter.cpp)
-astscf_component_add_files(logging-client IceConfigurator.cpp)
-astscf_component_add_files(logging-client IceLogger.cpp)
-astscf_component_add_files(logging-client OstreamLogger.cpp)
-astscf_component_add_files(logging-client IceConfigurator.h)
-astscf_component_add_files(logging-client ../../include/AsteriskSCF/logger.h)
-astscf_component_add_files(logging-client ../../include/AsteriskSCF/Logger/LogOut.h)
-astscf_component_add_files(logging-client ../../include/AsteriskSCF/Logger/LogConsts.h)
-astscf_component_add_files(logging-client ../../include/AsteriskSCF/Logger/IceLogger.h)
-astscf_component_add_files(logging-client ../../include/AsteriskSCF/Logger/Level.h)
-astscf_component_add_files(logging-client ../../include/AsteriskSCF/Logger/LogFormatter.h)
-astscf_component_add_boost_libraries(logging-client thread date_time filesystem system)
-astscf_component_add_ice_libraries(logging-client IceStorm)
-astscf_component_add_slice_collection_libraries(logging-client ASTSCF)
-astscf_component_build_library(logging-client)
-astscf_component_install(logging-client)
+astscf_component_init(LoggingClient)
+astscf_component_add_files(LoggingClient Logger.cpp)
+astscf_component_add_files(LoggingClient LoggerFactory.cpp)
+astscf_component_add_files(LoggingClient LogOut.cpp)
+astscf_component_add_files(LoggingClient LogFormatter.cpp)
+astscf_component_add_files(LoggingClient IceConfigurator.cpp)
+astscf_component_add_files(LoggingClient IceLogger.cpp)
+astscf_component_add_files(LoggingClient OstreamLogger.cpp)
+astscf_component_add_files(LoggingClient IceConfigurator.h)
+astscf_component_add_files(LoggingClient ../../include/AsteriskSCF/Logger.h)
+astscf_component_add_files(LoggingClient ../../include/AsteriskSCF/Logger/LogOut.h)
+astscf_component_add_files(LoggingClient ../../include/AsteriskSCF/Logger/LogConsts.h)
+astscf_component_add_files(LoggingClient ../../include/AsteriskSCF/Logger/IceLogger.h)
+astscf_component_add_files(LoggingClient ../../include/AsteriskSCF/Logger/Level.h)
+astscf_component_add_files(LoggingClient ../../include/AsteriskSCF/Logger/LogFormatter.h)
+astscf_component_add_boost_libraries(LoggingClient thread date_time filesystem system)
+astscf_component_add_ice_libraries(LoggingClient IceStorm)
+astscf_component_add_slice_collection_libraries(LoggingClient ASTSCF)
+astscf_component_build_library(LoggingClient)
+astscf_component_install(LoggingClient)
diff --git a/client/src/IceConfigurator.h b/client/src/IceConfigurator.h
index 404a46e..3348ecc 100644
--- a/client/src/IceConfigurator.h
+++ b/client/src/IceConfigurator.h
@@ -16,7 +16,7 @@
#pragma once
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
namespace AsteriskSCF
{
diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index e05e3d6..45787d3 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -17,7 +17,7 @@
#include <boost/date_time/posix_time/posix_time.hpp>
#include <boost/filesystem.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
using namespace AsteriskSCF::System::Logging;
using namespace std;
diff --git a/client/src/Logger.cpp b/client/src/Logger.cpp
index 7de61e3..924e0c3 100644
--- a/client/src/Logger.cpp
+++ b/client/src/Logger.cpp
@@ -24,7 +24,7 @@
#include <boost/thread/thread.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
using namespace AsteriskSCF::System::Logging;
diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index 0013c75..09d9e2e 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -25,7 +25,7 @@
#include <boost/algorithm/string/split.hpp>
#include <boost/thread/once.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
using namespace AsteriskSCF::System::Logging;
using namespace boost::algorithm;
diff --git a/client/src/OstreamLogger.cpp b/client/src/OstreamLogger.cpp
index 9d3aa0d..8d50274 100644
--- a/client/src/OstreamLogger.cpp
+++ b/client/src/OstreamLogger.cpp
@@ -19,7 +19,7 @@
#include <boost/interprocess/detail/os_thread_functions.hpp>
-#include <AsteriskSCF/logger.h>
+#include <AsteriskSCF/Logger.h>
#include <AsteriskSCF/Logger/LogFormatter.h>
using namespace AsteriskSCF::System::Logging;
diff --git a/include/AsteriskSCF/logger.h b/include/AsteriskSCF/logger.h
deleted file mode 100644
index 158cdd4..0000000
--- a/include/AsteriskSCF/logger.h
+++ /dev/null
@@ -1,502 +0,0 @@
-/*
- * Asterisk SCF -- An open-source communications framework.
- *
- * Copyright (C) 2010, Digium, Inc.
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk SCF project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE.txt file
- * at the top of the source tree.
- */
-
-#pragma once
-
-#include <ostream>
-#include <cstdarg>
-#include <string>
-
-#include <boost/shared_ptr.hpp>
-#include <boost/thread/locks.hpp>
-#include <boost/thread/mutex.hpp>
-#include <boost/thread/shared_mutex.hpp>
-#include <boost/weak_ptr.hpp>
-#include <boost/lexical_cast.hpp>
-
-#include <AsteriskSCF/System/Logger/LoggerIf.h>
-#include <AsteriskSCF/Logger/Level.h>
-#include <AsteriskSCF/Logger/LogOut.h>
-#include <AsteriskSCF/Logger/LogConsts.h>
-#include <AsteriskSCF/Logger/LogFormatter.h>
-
-namespace AsteriskSCF
-{
-namespace System
-{
-namespace Logging
-{
-
-/**
- * A streambuf for writing to a LogOut. Messages are written at newlines (\n)
- * or when destroyed. The way temporary object lifecycles work in C++, this is
- * very convenient.
- */
-class ASTSCF_DLL_EXPORT LogBuf : public std::streambuf
-{
-public:
- LogBuf(LogOut& out, const std::string& name, Level logLevel);
-
- /**
- * Copy ctor.
- * @param orig Original.
- */
- LogBuf(const LogBuf& orig);
-
- ~LogBuf();
-
-
- /**
- * Assignment probably never gets used, but just in case.
- */
- LogBuf& operator=(const LogBuf& orig);
-
-protected:
- int overflow(int c);
-
-private:
- std::stringbuf mBuffer;
- LogOut& mOut;
- std::string mName;
- Level mLogLevel;
-
- /**
- * Sends the current buffer to the formatter and clears it.
- */
- void sendBuffer();
-};
-
-/**
- * A ostream-like thing which will only process output if enabled. When
- * disabled, it very efficiently ignores operator<<() calls.
- */
-class CondStream
-{
-public:
- CondStream(LogOut& out, const std::string& name, Level level,
- bool enabled) :
- mBuf(out,name,level), mStream(&mBuf), mEnabled(enabled)
- {
- }
-
- /**
- * Copy ctor.
- * @param orig Original.
- */
- CondStream(const CondStream& orig) :
- mBuf(orig.mBuf), mStream(&mBuf), mEnabled(orig.mEnabled)
- {
-
- }
-
- /**
- * Output operator. Only does something when enabled == true.
- * @param val Value to output.
- * @return this.
- */
- template<typename T>
- CondStream& operator<<(const T& val);
-
- /**
- * Output operator for manipulators, such as endl.
- */
- CondStream& operator<<(std::ostream& (*pf)(std::ostream&));
-
-private:
- /**
- * streambuffer for writing characters.
- */
- LogBuf mBuf;
- /**
- * Ostream for processing output.
- */
- std::ostream mStream;
- /**
- * If false, operator<<() does nothing.
- */
- bool mEnabled;
-};
-
-template<typename T>
-inline CondStream& CondStream::operator<<(const T& val)
-{
- if (mEnabled)
- {
- mStream << val;
- }
- return *this;
-}
-
-inline CondStream& CondStream::operator<<(std::ostream& (*pf)(std::ostream&))
-{
- if (mEnabled)
- {
- mStream << pf;
- }
- return *this;
-}
-
-/**
- * The Logger for a particular source, identified by the given name. This is a
- * small wrapper class, which should be passed around by copy.
- */
-class Logger
-{
- // You may wonder why have this class at all. It only delegates to
- // LoggerImpl, so why not typedef shared_ptr<LoggerImpl> LoggerPtr
- // and use that? The problem with that approach is that we would lose
- // the stream style debugging, or at least may it a bit more cumbersome.
- // (*lg)(Debug) << "you'd have to dereference the smart pointer"
- // lg->stream(Debug) << "or have a named function"
-private:
- /** Implementation class */
- class LoggerImpl;
-public:
- /** Construct a Logger for an existing implementation */
- Logger(const boost::shared_ptr<LoggerImpl>& impl);
-
- /**
- * Construct a root Logger.
- */
- Logger(const std::string& name, LogOut& out, Level logLevel = Debug);
- /**
- * If true, this Logger would log messages of the given Level.
- *
- * @param level Level to check.
- * @return true if enabled for given level.
- */
- bool isEnabledFor(Level level) const;
- /**
- * Ostream style logging.
- *
- * @param level Level for messages sent to this stream.
- * @return LogStream that logs at the given level.
- */
- CondStream operator()(Level level) const;
- /**
- * Log a single message.
- */
- void logs(Level level, const std::string& message);
- /**
- * Log a single printf-formatted message.
- */
-#ifdef __GNUC__
- __attribute__((format(printf, 3, 4)))
-#endif
- void logf(Level level, char const *fmt, ...);
- /**
- * Log a single vprintf-formatted message.
- */
-#ifdef __GNUC__
- __attribute__((format(printf, 3, 0)))
-#endif
- void vlogf(Level level, char const *fmt, va_list ap);
- Logger getChild(const std::string& childName);
- std::vector<Logger> getChildren() const;
- const std::string& getName() const;
- LogOut& getOutput() const;
- void setOutput(LogOut& out);
- /**
- * Sets the current logLevel. Until unsetLevel() is called, we are no
- * longer affected by changes to our parent's log level.
- */
- void setLevel(Level logLevel);
- /**
- * Changes our logLevel to now inherit from our parent.
- */
- void unsetLevel();
- /**
- * Returns the effective level of this Logger.
- */
- Level getEffectiveLevel() const;
-private:
- boost::shared_ptr<LoggerImpl> mImpl;
-};
-
-
-class Logger::LoggerImpl
-{
-public:
- /**
- * Construct a root Logger.
- */
- ASTSCF_DLL_EXPORT LoggerImpl(const std::string& name, LogOut& out,
- Level logLevel = Debug);
- /**
- * Construct a child Logger.
- */
- ASTSCF_DLL_EXPORT LoggerImpl(
- const boost::shared_ptr<LoggerImpl>& parent, const std::string& name);
-
- ASTSCF_DLL_EXPORT ~LoggerImpl();
-
- /**
- * If true, this Logger would log messages of the given Level.
- *
- * @param level Level to check.
- * @return true if enabled for given level.
- */
- bool isEnabledFor(Level level) const
- {
- return level >= getEffectiveLevel();
- }
- /**
- * Ostream style logging.
- *
- * @param level Level for messages sent to this stream.
- * @return LogStream that logs at the given level.
- */
- ASTSCF_DLL_EXPORT CondStream operator()(Level level) const;
-
- /**
- * Log a single message.
- */
- ASTSCF_DLL_EXPORT void logs(Level level, const std::string& message) const;
-
- /**
- * Log a single vprintf-formatted message.
- */
-#ifdef __GNUC__
- __attribute__((format(printf, 3, 0)))
-#endif
- ASTSCF_DLL_EXPORT void vlogf(Level level, char const *fmt, va_list ap) const;
-
- ASTSCF_DLL_EXPORT Logger getChild(
- const boost::shared_ptr<LoggerImpl>& self, const std::string& childName);
- ASTSCF_DLL_EXPORT std::vector<Logger> getChildren() const;
-
- const std::string& getName() const
- {
- return mName;
- }
-
- LogOut& getOutput() const
- {
- return *mOut;
- }
-
- ASTSCF_DLL_EXPORT void setOutput(LogOut& out);
-
- /**
- * Sets the current logLevel. Until unsetLevel() is called, we are no
- * longer affected by changes to our parent's log level.
- */
- ASTSCF_DLL_EXPORT void setLevel(Level logLevel);
-
- /**
- * Changes our logLevel to now inherit from out parent.
- */
- ASTSCF_DLL_EXPORT void unsetLevel();
-
- /**
- * Returns the effective level of this Logger.
- */
- ASTSCF_DLL_EXPORT Level getEffectiveLevel() const;
-
-private:
- // non-copyable
- LoggerImpl(const Logger&);
- const LoggerImpl& operator=(const LoggerImpl&);
-
- /**
- * Mutex for access to the children field.
- */
- mutable boost::mutex mChildrenMutex;
-
- /**
- * Parent pointer. We cannot change which parent we have, nor can we change
- * our parent.
- *
- * This can't be a shared_ptr, because then the circular reference would
- * cause memory leaks.
- *
- * It also can't be a raw pointer, since children can outlive their parents.
- */
- boost::weak_ptr<LoggerImpl const> const mParent;
- typedef std::map<std::string, boost::shared_ptr<LoggerImpl> > Children;
- /**
- * Map of children. The key is the next final node in that child's name.
- */
- Children mChildren;
- /**
- * Name of this logger, in dotted-notation.
- */
- const std::string mName;
- /**
- * Output for log messages.
- */
- LogOut *mOut;
- /**
- * Mutex for accessing mLogLevel and mInherited. It's a shared_mutex
- * to reduce read contention on the mutex.
- */
- mutable boost::shared_mutex mInheritedMutex;
- /**
- * Current level of this Logger. Only applicable if inheritedLevel == false.
- */
- Level mLogLevel;
- /**
- * If true, then our effectiveLevel == parent->effectiveLevel
- */
- bool mInheritedLevel;
-};
-
-
-// since these are all simple delegates to LoggerImpl, inline them
-
-inline Logger::Logger(const boost::shared_ptr<LoggerImpl>& impl) :
- mImpl(impl)
-{
-}
-
-
-inline Logger::Logger(const std::string& name, LogOut& out, Level logLevel) :
- mImpl(new LoggerImpl(name, out, logLevel))
-{
-}
-
-
-inline bool Logger::isEnabledFor(Level level) const
-{
- return mImpl->isEnabledFor(level);
-}
-
-
-inline CondStream Logger::operator()(Level level) const
-{
- return (*mImpl)(level);
-}
-
-
-inline void Logger::logs(Level level, const std::string& message)
-{
- mImpl->logs(level, message);
-}
-
-
-inline void Logger::logf(Level level, char const *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- try
- {
- mImpl->vlogf(level, fmt, ap);
- }
- catch(...)
- {
- va_end(ap);
- throw;
- }
- va_end(ap);
-}
-
-
-inline void Logger::vlogf(Level level, char const *fmt, va_list ap)
-{
- mImpl->vlogf(level, fmt, ap);
-}
-
-
-inline Logger Logger::getChild(const std::string& childName)
-{
- return mImpl->getChild(mImpl, childName);
-}
-
-
-inline std::vector<Logger> Logger::getChildren() const
-{
- return mImpl->getChildren();
-}
-
-
-inline const std::string& Logger::getName() const
-{
- return mImpl->getName();
-}
-
-
-inline LogOut& Logger::getOutput() const
-{
- return mImpl->getOutput();
-}
-
-
-inline void Logger::setOutput(LogOut& out)
-{
- mImpl->setOutput(out);
-}
-
-
-inline void Logger::setLevel(Level logLevel)
-{
- mImpl->setLevel(logLevel);
-}
-
-
-inline void Logger::unsetLevel()
-{
- mImpl->unsetLevel();
-}
-
-
-inline Level Logger::getEffectiveLevel() const
-{
- return mImpl->getEffectiveLevel();
-}
-
-
-/**
- * Main entry point into the Logger system.
- */
-class LoggerFactory
-{
-public:
- ASTSCF_DLL_EXPORT LoggerFactory(LogOut& out);
-
- /**
- * Will get the Logger with the given name. If the Logger does not exist,
- * it will be created.
- *
- * @param name Name of the Logger to be retrieved.
- * @return Ref to the Logger.
- * @thread-safe
- */
- ASTSCF_DLL_EXPORT Logger getLogger(const std::string& name);
-
- /**
- * Returns a vector of the names of all currently configured Logger's.
- * @return Vector of Logger names.
- */
- ASTSCF_DLL_EXPORT std::vector<std::string> getLoggerNames() const;
-
- ASTSCF_DLL_EXPORT void setLogOutput(LogOut& out);
-
-private:
- Logger mRoot;
-
- static void accumulateLoggerNames(Logger logger, std::vector<std::string>& out);
-};
-
-ASTSCF_DLL_EXPORT boost::shared_ptr<LogOut> buildOstreamLogger(std::ostream& out, const std::string& FmtStr = DefaultLogFormat);
-
-/**
- * Returns the default configured LoggerFactory.
- */
-ASTSCF_DLL_EXPORT LoggerFactory& getLoggerFactory();
-
-} // Logging
-} // System
-} // AsteriskSCF
diff --git a/server/src/CMakeLists.txt b/server/src/CMakeLists.txt
index cb4f86f..5aced67 100644
--- a/server/src/CMakeLists.txt
+++ b/server/src/CMakeLists.txt
@@ -1,33 +1,33 @@
-astscf_component_init(logging-service-lib)
+astscf_component_init(LoggingServiceLib)
# an icebox module cannot be used as a shared lib, so build the bulk of the
# code as a static lib that can be linked into both the icebox module and
# the unit tests
-astscf_component_add_files(logging-service-lib ChainedLogOut.cpp)
-astscf_component_add_files(logging-service-lib FileChainedLogOut.cpp)
-astscf_component_add_files(logging-service-lib LoggingServer.cpp)
-astscf_component_add_files(logging-service-lib OstreamChainedLogOut.cpp)
-astscf_component_add_files(logging-service-lib Configuration.cpp)
-astscf_component_add_files(logging-service-lib ChainedLogOut.h)
-astscf_component_add_files(logging-service-lib FileChainedLogOut.h)
-astscf_component_add_files(logging-service-lib OstreamChainedLogOut.h)
-astscf_component_add_files(logging-service-lib LoggingServer.h)
-astscf_component_add_files(logging-service-lib Configuration.h)
-astscf_component_add_files(logging-service-lib ../../client/src/LogFormatter.cpp)
-astscf_component_add_files(logging-service-lib ../../client/src/LogOut.cpp)
-astscf_component_add_slices(logging-service-lib PROJECT AsteriskSCF/Configuration/LoggingService/LoggingConfigurationIf.ice)
-astscf_component_add_boost_libraries(logging-service-lib core thread filesystem date_time system)
-astscf_component_add_ice_libraries(logging-service-lib IceStorm)
-astscf_component_add_slice_collection_libraries(logging-service-lib ASTSCF)
-astscf_component_build_library(logging-service-lib STATIC)
+astscf_component_add_files(LoggingServiceLib ChainedLogOut.cpp)
+astscf_component_add_files(LoggingServiceLib FileChainedLogOut.cpp)
+astscf_component_add_files(LoggingServiceLib LoggingServer.cpp)
+astscf_component_add_files(LoggingServiceLib OstreamChainedLogOut.cpp)
+astscf_component_add_files(LoggingServiceLib Configuration.cpp)
+astscf_component_add_files(LoggingServiceLib ChainedLogOut.h)
+astscf_component_add_files(LoggingServiceLib FileChainedLogOut.h)
+astscf_component_add_files(LoggingServiceLib OstreamChainedLogOut.h)
+astscf_component_add_files(LoggingServiceLib LoggingServer.h)
+astscf_component_add_files(LoggingServiceLib Configuration.h)
+astscf_component_add_files(LoggingServiceLib ../../client/src/LogFormatter.cpp)
+astscf_component_add_files(LoggingServiceLib ../../client/src/LogOut.cpp)
+astscf_component_add_slices(LoggingServiceLib PROJECT AsteriskSCF/Configuration/LoggingService/LoggingConfigurationIf.ice)
+astscf_component_add_boost_libraries(LoggingServiceLib core thread filesystem date_time system)
+astscf_component_add_ice_libraries(LoggingServiceLib IceStorm)
+astscf_component_add_slice_collection_libraries(LoggingServiceLib ASTSCF)
+astscf_component_build_library(LoggingServiceLib STATIC)
# This lib is compiled into a .so, so it needs -fPIC set
if(CMAKE_COMPILER_IS_GNUCXX)
- set_target_properties(logging-service-lib PROPERTIES COMPILE_FLAGS -fPIC)
+ set_target_properties(LoggingServiceLib PROPERTIES COMPILE_FLAGS -fPIC)
endif()
# icebox module
-astscf_component_init(logging-service)
-astscf_component_add_files(logging-service main.cpp)
-astscf_component_build_icebox(logging-service)
-target_link_libraries(logging-service logging-service-lib)
-astscf_component_install(logging-service)
+astscf_component_init(LoggingService)
+astscf_component_add_files(LoggingService Component.cpp)
+astscf_component_build_icebox(LoggingService)
+target_link_libraries(LoggingService LoggingServiceLib)
+astscf_component_install(LoggingService)
diff --git a/server/src/main.cpp b/server/src/Component.cpp
similarity index 100%
rename from server/src/main.cpp
rename to server/src/Component.cpp
-----------------------------------------------------------------------
--
asterisk-scf/release/logger.git
More information about the asterisk-scf-commits
mailing list