[asterisk-scf-commits] asterisk-scf/integration/logger.git branch "logformat" updated.
Commits to the Asterisk SCF project code repositories
asterisk-scf-commits at lists.digium.com
Thu Sep 1 16:29:45 CDT 2011
branch "logformat" has been updated
via 94ed3592c58b590806ba0dcbfd57826240abcd63 (commit)
via fcee6e43a1a37489174e9bb25e60074044492b62 (commit)
via bb3701dc70706e14e7def66d8560f47b96eeacef (commit)
via 1d64744c3d255ffae0447d3c157e2bda220eb560 (commit)
from cc9fca2050b09b8164b7dc39b0f6a61d2e427546 (commit)
Summary of changes:
CMakeLists.txt | 6 +-
client/src/IceLogger.cpp | 30 ++++--
client/src/LogFormatter.cpp | 128 +++++++++++++++---------
client/src/LoggerFactory.cpp | 5 +-
client/src/OstreamLogger.cpp | 25 +++++-
client/test/Logger-test.cpp | 7 +-
include/AsteriskSCF/Logger/IceLogger.h | 7 +-
include/AsteriskSCF/Logger/LogFormatter.h | 25 ++++--
include/AsteriskSCF/Logger/LogOut.h | 4 +
include/AsteriskSCF/logger.h | 5 -
server/config/testloggingserver.conf | 13 +++
server/local-slice/LoggingConfigurationIf.ice | 29 +++++-
server/src/CMakeLists.txt | 2 +-
server/src/Configuration.cpp | 8 +-
server/src/LoggingServer.cpp | 8 +-
server/src/LoggingServer.h | 7 +-
server/src/main.cpp | 1 -
server/test/CMakeLists.txt | 8 +-
server/test/ConfigurationTest.cpp | 7 +-
server/test/LoggingConfigurationHelper.cpp | 4 +-
20 files changed, 229 insertions(+), 100 deletions(-)
- Log -----------------------------------------------------------------
commit 94ed3592c58b590806ba0dcbfd57826240abcd63
Author: Ken Hunt <ken.hunt at digium.com>
Date: Thu Sep 1 16:28:30 2011 -0500
Updated to run on Windows. Uses boost for date/time access and formatting.
Uses boost to access process id. Added support for specifying and formatting with the
component's service locator params (category/service/id).
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b903e93..4d61dac 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@ asterisk_scf_component_add_file(logging-client include/AsteriskSCF/Logger/LogCon
asterisk_scf_component_add_file(logging-client include/AsteriskSCF/Logger/LogFormatter.h)
asterisk_scf_component_add_file(logging-client include/AsteriskSCF/Logger/IceLogger.h)
asterisk_scf_component_add_file(logging-client include/AsteriskSCF/Logger/Level.h)
-asterisk_scf_component_add_boost_libraries(logging-client thread date_time)
+asterisk_scf_component_add_boost_libraries(logging-client thread date_time system)
asterisk_scf_component_add_ice_libraries(logging-client IceStorm)
include_directories(${API_INCLUDE_DIR})
diff --git a/client/src/IceLogger.cpp b/client/src/IceLogger.cpp
index 11b17c4..6f86efc 100644
--- a/client/src/IceLogger.cpp
+++ b/client/src/IceLogger.cpp
@@ -14,7 +14,8 @@
* at the top of the source tree.
*/
-#include <unistd.h>
+#include <boost/asio/ip/host_name.hpp>
+#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <IceStorm/IceStorm.h>
@@ -33,15 +34,19 @@ void IceLogger::logs(const std::string& name, Level logLevel,
bool logged = false;
try
{
+
+ std::string hostName = boost::asio::ip::host_name();
+
if (mServer)
{
- char c_hostname[HOSTNAME_SIZE];
-
- if (gethostname(c_hostname,HOSTNAME_SIZE))
- {
- std::strncpy(c_hostname,"unknown_host",HOSTNAME_SIZE);
- }
- mServer->logs(name, logLevel, message, getpid(), std::string(c_hostname));
+ mServer->logs(name,
+ logLevel,
+ message,
+ hostName,
+ (Ice::Long)boost::interprocess::detail::get_current_process_id(),
+ mComponentCategory,
+ mComponentServiceName,
+ mComponentId);
logged = true;
}
}
@@ -68,6 +73,15 @@ void IceLogger::logs(const std::string& name, Level logLevel,
}
}
+void IceLogger::setComponentInfo(const std::string& componentCategory,
+ const std::string& serviceName,
+ const std::string& id)
+{
+ mComponentCategory = componentCategory;
+ mComponentServiceName = serviceName;
+ mComponentId = id;
+}
+
IceUtil::Handle<ConfiguredIceLogger> ConfiguredIceLogger::create(
const LoggingServerPrx& server)
{
diff --git a/client/src/LogFormatter.cpp b/client/src/LogFormatter.cpp
index 089fbcd..9ee6495 100644
--- a/client/src/LogFormatter.cpp
+++ b/client/src/LogFormatter.cpp
@@ -14,28 +14,28 @@
* at the top of the source tree.
*/
+#include "boost/date_time/posix_time/posix_time.hpp"
+
#include <AsteriskSCF/logger.h>
using namespace AsteriskSCF::System::Logging;
+using namespace std;
LogFormatter::LogFormatter(const std::string& fmtStr) :
mFormat(fmtStr), mLastMsgTime(boost::posix_time::microsec_clock::universal_time())
{
}
-
LogFormatter::~LogFormatter()
{
}
-
void LogFormatter::setFormat(const std::string& fmtStr)
{
boost::unique_lock<boost::shared_mutex> lock(mMutex);
mFormat = fmtStr;
}
-
std::string LogFormatter::getFormat()
{
boost::shared_lock<boost::shared_mutex> lock(mMutex);
@@ -43,22 +43,53 @@ std::string LogFormatter::getFormat()
return mFormat;
}
+std::string getNowString(const boost::posix_time::ptime& now, const std::string& format)
+{
+ boost::posix_time::time_facet* outputFacet = new boost::posix_time::time_facet();
+
+ std::stringstream ss;
+ ss.imbue(std::locale(std::locale::classic(), outputFacet));
+ outputFacet->format(format.c_str());
+
+ ss << now;
+
+ return ss.str();
+}
+
+std::string getNowString(const boost::posix_time::ptime& now)
+{
+ std::stringstream ss;
+
+ ss << now;
+ return ss.str();
+}
/**
* Formats a log string and returns it for output
*/
std::string LogFormatter::formatMessage(const std::string& message, const std::string& name, Level level,
- long pid, const std::string& hostname)
+ const std::string& hostName, Ice::Long pid,
+ const std::string& componentCategory, const std::string& serviceId, const std::string& instanceId)
{
- std::string outStr = getFormat();
+ boost::posix_time::ptime now(boost::posix_time::microsec_clock::universal_time());
+ boost::posix_time::time_duration deltaTime;
+ std::string outStr;
std::size_t pos;
- if ((pos=outStr.find(SPECIFIER("n"),0))!=std::string::npos)
+ { // protected section to grab the format, and to update the last message time.
+ boost::shared_lock<boost::shared_mutex> lock(mMutex);
+ outStr = mFormat;
+ deltaTime = now - mLastMsgTime;
+ mLastMsgTime = now;
+ }
+
+ if ((pos=outStr.find(SPECIFIER("n"),0)) != std::string::npos)
{
// Logger name
outStr.replace(pos,2,name);
}
- if ((pos=outStr.find(SPECIFIER("l"),0))!=std::string::npos)
+
+ if ((pos=outStr.find(SPECIFIER("l"),0)) != std::string::npos)
{
// Priority / level
std::stringstream s("");
@@ -66,35 +97,29 @@ std::string LogFormatter::formatMessage(const std::string& message, const std::s
s << level;
outStr.replace(pos,2,s.str());
}
- if ((pos=outStr.find(SPECIFIER("h"),0))!=std::string::npos)
+
+ if ((pos=outStr.find(SPECIFIER("h"),0)) != std::string::npos)
{
// Client host name
- if (hostname.size()==0)
+ if (hostName.size()==0)
{
- char host[HOSTNAME_SIZE];
-
- if (gethostname(host,HOSTNAME_SIZE))
- {
- std::strncpy(host,"unknown_host",HOSTNAME_SIZE);
- }
- outStr.replace(pos,2,std::string(host));
+ outStr.replace(pos,2,"");
}
- else outStr.replace(pos,2,hostname);
+ else outStr.replace(pos,2,hostName);
}
- if ((pos=outStr.find(SPECIFIER("t{"),0))!=std::string::npos)
+
+ if ((pos=outStr.find(SPECIFIER("t{"),0)) != std::string::npos)
{
// Client timestamp (formatted)
try
{
std::size_t pos2 = outStr.find("}",pos+3);
- if (pos2!=std::string::npos)
+ if (pos2 != std::string::npos)
{
- std::string timeFormat = outStr.substr(pos+3,pos2-3);
- time_t now = time(NULL);
- char timeStamp[TIMESTAMP_SIZE];
-
- strftime(timeStamp,TIMESTAMP_SIZE,timeFormat.c_str(),localtime(&now));
- outStr.replace(pos,pos+pos2+1,std::string(timeStamp));
+ std::string userTimeFormat = outStr.substr(pos+3,pos2-3);
+ std::string nowStr = getNowString(now, userTimeFormat);
+
+ outStr.replace(pos,pos+pos2+1,nowStr);
}
}
catch (...)
@@ -103,45 +128,52 @@ std::string LogFormatter::formatMessage(const std::string& message, const std::s
// in the output and signal to someone that the format is wrong
}
}
- else if ((pos=outStr.find(SPECIFIER("t"),0))!=std::string::npos)
+ else if ((pos=outStr.find(SPECIFIER("t"),0)) != std::string::npos)
{
// Client timestamp (unformatted)
- char timeStamp[TIMESTAMP_SIZE];
- std::time_t now = time(NULL);
-
- strftime(timeStamp,TIMESTAMP_SIZE,TimestampFormat.c_str(),localtime(&now));
- outStr.replace(pos,2,std::string(timeStamp));
+ string nowString = getNowString(now);
+
+ outStr.replace(pos,2,nowString);
}
- if ((pos=outStr.find(SPECIFIER("p"),0))!=std::string::npos)
+
+ if ((pos=outStr.find(SPECIFIER("p"),0)) != std::string::npos)
{
// Process ID
- if (!pid)
- {
- outStr.replace(pos,2,boost::lexical_cast<std::string>(getpid()));
- }
- else
- {
- outStr.replace(pos,2,boost::lexical_cast<std::string>(pid));
- }
+ outStr.replace(pos,2,boost::lexical_cast<std::string>(pid));
}
- if ((pos=outStr.find(SPECIFIER("d"),0))!=std::string::npos)
+
+ if ((pos=outStr.find(SPECIFIER("d"),0)) != std::string::npos)
{
- // Time delta since last message
- boost::posix_time::time_duration delta =
- boost::posix_time::microsec_clock::universal_time() - mLastMsgTime;
+ //deltaTime.
// take labs() on the off chance delta represents a negative duration
- long secs = labs(delta.total_milliseconds() / 1000),
- msecs = labs(delta.total_milliseconds() % 1000);
+ boost::posix_time::time_duration::tick_type secs = (deltaTime.total_milliseconds() / 1000);
+ boost::posix_time::time_duration::tick_type msecs = (deltaTime.total_milliseconds() % 1000);
std::stringstream s("");
s << secs << "." << std::setfill('0') << std::setw(3) << msecs;
outStr.replace(pos,2,s.str());
}
- if ((pos=outStr.find(SPECIFIER("m"),0))!=std::string::npos)
+
+ if ((pos=outStr.find(SPECIFIER("C"),0)) != std::string::npos)
+ {
+ outStr.replace(pos, 2, componentCategory);
+ }
+
+ if ((pos=outStr.find(SPECIFIER("S"),0)) != std::string::npos)
+ {
+ outStr.replace(pos, 2, serviceId);
+ }
+
+ if ((pos=outStr.find(SPECIFIER("I"),0)) != std::string::npos)
+ {
+ outStr.replace(pos, 2, instanceId);
+ }
+
+ if ((pos=outStr.find(SPECIFIER("m"),0)) != std::string::npos)
{
// Check for message specifier last so we don't modify the message itself
outStr.replace(pos,2,message);
}
- mLastMsgTime = boost::posix_time::microsec_clock::universal_time();
+
return outStr;
}
diff --git a/client/src/LoggerFactory.cpp b/client/src/LoggerFactory.cpp
index 07fe13b..45e1fb7 100644
--- a/client/src/LoggerFactory.cpp
+++ b/client/src/LoggerFactory.cpp
@@ -14,6 +14,7 @@
* at the top of the source tree.
*/
+
#include <string>
#include <map>
#include <vector>
@@ -22,6 +23,7 @@
#include <iostream>
+#include <boost/filesystem.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/thread/once.hpp>
#include <AsteriskSCF/logger.h>
@@ -76,7 +78,8 @@ std::string AsteriskSCF::System::Logging::sourceInfoStr(const std::string& fmt,
}
if ((pos=s.find(SPECIFIER("sf"),0))!=std::string::npos)
{
- s.replace(pos,3,boost::lexical_cast<std::string>(basename(file)));
+ boost::filesystem::path p(file);
+ s.replace(pos,3,boost::lexical_cast<std::string>(p.leaf()));
found = true;
}
}
diff --git a/client/src/OstreamLogger.cpp b/client/src/OstreamLogger.cpp
index a42c2a2..1168cc7 100644
--- a/client/src/OstreamLogger.cpp
+++ b/client/src/OstreamLogger.cpp
@@ -15,6 +15,11 @@
*/
#include <boost/shared_ptr.hpp>
+#include <boost/asio/ip/host_name.hpp>
+
+// NOTE: It is far from ideal to rely on the detail files of boost. But there is currently no
+// better alternative to a portable process id.
+#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <AsteriskSCF/logger.h>
#include <AsteriskSCF/Logger/LogFormatter.h>
@@ -30,19 +35,37 @@ public:
OstreamLogger(std::ostream& out, const std::string& fmtStr = DefaultLogFormat) :
mOut(out), mFormatter(fmtStr)
{
+ mProcessId = (Ice::Long)boost::interprocess::detail::get_current_process_id();
+ mHostName = boost::asio::ip::host_name();
}
void logs(const std::string& name, Level level,
const std::string& message)
{
boost::unique_lock<boost::mutex> lock(mMutex);
- mOut << mFormatter.formatMessage(message,name,level) << '\n';
+ mOut << mFormatter.formatMessage(message,name,level,mHostName,mProcessId,mComponentCategory,mServiceId,mComponentId) << '\n';
+ }
+
+ void setComponentInfo(const std::string& componentCategory,
+ const std::string& serviceId,
+ const std::string& id)
+ {
+ mComponentCategory = componentCategory;
+ mServiceId = serviceId;
+ mComponentId = id;
}
private:
std::ostream& mOut;
boost::mutex mMutex;
+
+ std::string mComponentCategory;
+ std::string mServiceId;
+ std::string mComponentId;
+ std::string mHostName;
+ Ice::Long mProcessId;
+
/**
* Current formatter for this logger
*/
diff --git a/client/test/Logger-test.cpp b/client/test/Logger-test.cpp
index 64fadd2..b86aa52 100644
--- a/client/test/Logger-test.cpp
+++ b/client/test/Logger-test.cpp
@@ -17,6 +17,7 @@
#include <sstream>
#include <boost/test/unit_test.hpp>
+#include <boost/asio/ip/host_name.hpp>
#include <AsteriskSCF/logger.h>
#include "ExpectedLogOut.h"
@@ -109,7 +110,9 @@ BOOST_AUTO_TEST_CASE(test_stream_format)
{
char host[120];
- BOOST_REQUIRE(gethostname(host,120)==0);
+ std::string hostName = boost::asio::ip::host_name();
+
+ BOOST_REQUIRE(hostName.length() != 0);
ExpectedLogOut out("Debug:src:"+std::string(host)+": debug f00d\n",
"$l:$n:$h: $m");
@@ -145,7 +148,7 @@ BOOST_AUTO_TEST_CASE(test_stream_timedelta)
// This is probably not the best test, since it's theoretically possible
// for more than one millisecond to pass between the creation of the
// expected message above and the actual message below.
- usleep(1000); // force a millisecond to pass
+ IceUtil::ThreadControl::sleep(IceUtil::Time::milliSeconds(500)); // allow time to pass
uut(Debug) << "TimeDelta test" << '\n';
out.check();
}
diff --git a/include/AsteriskSCF/Logger/IceLogger.h b/include/AsteriskSCF/Logger/IceLogger.h
index 3719f99..1e386f3 100644
--- a/include/AsteriskSCF/Logger/IceLogger.h
+++ b/include/AsteriskSCF/Logger/IceLogger.h
@@ -31,13 +31,18 @@ public:
void logs(const std::string& name, Level logLevel,
const std::string& message);
-
+ void setComponentInfo(const std::string& componentCategory,
+ const std::string& serviceName,
+ const std::string& id);
const LoggingServerPrx& getServer() const { return mServer; }
void setServer(const LoggingServerPrx& server) { this->mServer = server; }
private:
LoggingServerPrx mServer;
bool mHasPrintedNoServerNotice;
+ std::string mComponentCategory;
+ std::string mComponentServiceName;
+ std::string mComponentId;
};
/**
diff --git a/include/AsteriskSCF/Logger/LogFormatter.h b/include/AsteriskSCF/Logger/LogFormatter.h
index 566d4c8..8336c32 100644
--- a/include/AsteriskSCF/Logger/LogFormatter.h
+++ b/include/AsteriskSCF/Logger/LogFormatter.h
@@ -59,21 +59,29 @@ namespace Logging
* Class used to format log messages. The LogFormatter uses a format string to
* describe what a formatted log message should look like.
*
- * The format string is composed of format specifiers and other text, much like
- * the printf statement. Valid format specifiers are (the $ is really whatever is
- * defined by the SPECIFIER macro) :
+ * The format string is composed of format parameters and other text, much like
+ * the printf statement. Valid format parameters are:
*
* $n - the name of the logger
* $l - the level of the message being logged
* $h - the client host name
* $t - current time, can be further formatted with additional specifiers following the
- * strftime() format. The additional specifiers should be in a set of curly braces,
+ * boost::posix_time::time_facet format, which is similar to the strftime() format.
+ * The additional specifiers should be in a set of curly braces,
* like: $t{%x %X} would format the time into a date/time string. If no additional
- * format specifiers are given (ie, just $t), the system uses whatever the
- * TimestampFormat const is set to.
+ * format specifiers are given (ie, just $t), the system uses the default
+ * time format.
* $p - current process id
* $d - delta in time between this message and the last one (shows as seconds.milliseconds)
* $m - the message to log. You probably always want this one in your format string.
+ *
+ * $C - component category. This is part of the Service Locator params for the Component
+ * Service for the component performing the logging.
+ * $S - service name. This is part of the Service Locator params for the Component
+ * Service for the component performing the logging.
+ * $I - component instance id. This is part of the Service Locator params for the Component
+ * Service for the component performing the logging.
+ * $L - The service locator params triad with commas between items. Same as specifying: "$C,$S,$I"
*/
class LogFormatter
@@ -83,8 +91,9 @@ public:
~LogFormatter();
void setFormat(const std::string& fmtStr);
std::string getFormat();
- std::string formatMessage(const std::string& message, const std::string& name, Level level, long pid = 0,
- const std::string& hostname = "");
+ std::string formatMessage(const std::string& message, const std::string& name, Level level,
+ const std::string& hostName, Ice::Long pid,
+ const std::string& componentCategory, const std::string& serviceId, const std::string& componentId);
private:
std::string mFormat;
boost::posix_time::ptime mLastMsgTime;
diff --git a/include/AsteriskSCF/Logger/LogOut.h b/include/AsteriskSCF/Logger/LogOut.h
index 56efca5..f0aa153 100644
--- a/include/AsteriskSCF/Logger/LogOut.h
+++ b/include/AsteriskSCF/Logger/LogOut.h
@@ -38,6 +38,10 @@ public:
ASTERISK_SCF_ICEBOX_EXPORT virtual ~LogOut();
ASTERISK_SCF_ICEBOX_EXPORT virtual void logs(const std::string& name, Level logLevel,
const std::string& message) = 0;
+ ASTERISK_SCF_ICEBOX_EXPORT virtual void setComponentInfo(
+ const std::string& componentCategory,
+ const std::string& serviceName,
+ const std::string& id) = 0;
};
diff --git a/include/AsteriskSCF/logger.h b/include/AsteriskSCF/logger.h
index d0b0e42..5dde016 100644
--- a/include/AsteriskSCF/logger.h
+++ b/include/AsteriskSCF/logger.h
@@ -482,11 +482,6 @@ ASTERISK_SCF_ICEBOX_EXPORT boost::shared_ptr<LogOut> buildOstreamLogger(std::ost
*/
ASTERISK_SCF_ICEBOX_EXPORT LoggerFactory& getLoggerFactory();
-
-ASTERISK_SCF_ICEBOX_EXPORT std::string formatLogString(const std::string& fmt, const std::string& msg,
- Level level, const std::string& name, const boost::posix_time::time_duration& delta);
-
-
} // Logging
} // System
} // AsteriskSCF
diff --git a/server/config/testloggingserver.conf b/server/config/testloggingserver.conf
index b16c9a0..537b754 100644
--- a/server/config/testloggingserver.conf
+++ b/server/config/testloggingserver.conf
@@ -35,4 +35,17 @@ AsteriskSCFIceStorm.TopicManager.Endpoints=default -p 10000
#
AsteriskSCFIceStorm.Publish.Endpoints=tcp -p 10001:udp -p 10001
+#
+# TopicManager Tracing
+#
+# 0 = no tracing
+# 1 = trace topic creation, subscription, unsubscription
+# 2 = like 1, but with more detailed subscription information
+#
+AsteriskSCFIceStorm.Trace.TopicManager=2
+AsteriskSCFIceStorm.Transient=1
+
+#
+AsteriskSCFIceStorm.Flush.Timeout=2000
+
LoggerTestAdapter.Endpoints=default
diff --git a/server/local-slice/LoggingConfigurationIf.ice b/server/local-slice/LoggingConfigurationIf.ice
index ee683c1..ba39029 100644
--- a/server/local-slice/LoggingConfigurationIf.ice
+++ b/server/local-slice/LoggingConfigurationIf.ice
@@ -78,10 +78,31 @@ module V1
*/
class FormatItem extends LoggerConfigurationItem
{
- /**
- * The name of the file to send output to
- */
- string fmtStr;
+ /**
+ * String describing the logger format.
+ * The format string is composed of format parameters and other text, much like
+ * the printf statement. Valid format parameters are:
+ *
+ * $n - the name of the logger
+ * $l - the level of the message being logged
+ * $h - the client host name
+ * $t - current time, can be further formatted with additional specifiers following the
+ * boost::posix_time::time_facet format, which is similar to the strftime() format.
+ * The additional specifiers should be in a set of curly braces,
+ * like: $t{%x %X} would format the time into a date/time string. If no additional
+ * format specifiers are given (ie, just $t), the system uses the default
+ * time format.
+ * $p - current process id
+ * $d - delta in time between this message and the last one (shows as seconds.milliseconds)
+ * $m - the message to log. You probably always want this one in your format string.
+ * $C - component category. This is part of the Service Locator params for the Component
+ * Service for the component performing the logging.
+ * $S - service name. This is part of the Service Locator params for the Component
+ * Service for the component performing the logging.
+ * $I - component instance id. This is part of the Service Locator params for the Component
+ * Service for the component performing the logging.
+ */
+ string formatSpec;
};
}; //end module V1
diff --git a/server/src/CMakeLists.txt b/server/src/CMakeLists.txt
index d4a64a5..b7bd287 100644
--- a/server/src/CMakeLists.txt
+++ b/server/src/CMakeLists.txt
@@ -20,7 +20,7 @@ asterisk_scf_component_add_file(logging-service-lib OstreamChainedLogOut.h)
asterisk_scf_component_add_file(logging-service-lib LoggingServer.h)
asterisk_scf_component_add_file(logging-service-lib Configuration.h)
asterisk_scf_component_add_slice(logging-service-lib ../local-slice/LoggingConfigurationIf.ice)
-asterisk_scf_component_add_boost_libraries(logging-service-lib thread core)
+asterisk_scf_component_add_boost_libraries(logging-service-lib thread core date_time)
asterisk_scf_component_add_ice_libraries(logging-service-lib IceStorm)
asterisk_scf_component_build_library(logging-service-lib)
target_link_libraries(logging-service-lib asterisk-scf-api)
diff --git a/server/src/Configuration.cpp b/server/src/Configuration.cpp
index 2902ced..564a25b 100644
--- a/server/src/Configuration.cpp
+++ b/server/src/Configuration.cpp
@@ -57,7 +57,7 @@ public:
: mServer(server)
{
printf("FormatItem constructor, this = %p\n",this);
- fmtStr = fmt;
+ formatSpec = fmt;
mServer->setFormat(fmt);
}
~FormatItemI()
@@ -271,7 +271,7 @@ void LoggerConfigurationService::setConfiguration(const ConfigurationGroupSeq& g
void visitFormatItem(const FormatItemPtr& formatItem)
{
printf("Calling format constructor\n");
- mPriv->mGeneralConfiguration->mFormat = new FormatItemI(mPriv->mServer, formatItem->fmtStr);
+ mPriv->mGeneralConfiguration->mFormat = new FormatItemI(mPriv->mServer, formatItem->formatSpec);
printf("Back from calling format constructor\n");
}
ConfigurationServicePrivPtr mPriv;
@@ -350,9 +350,9 @@ void LoggerConfigurationService::removeConfigurationItems(const ConfigurationGro
}
void visitFormatItem(const FormatItemPtr& formatItem)
{
- if (mGroup->mFormat->fmtStr == formatItem->fmtStr)
+ if (mGroup->mFormat->formatSpec == formatItem->formatSpec)
{
- mGroup->mFormat->fmtStr = DefaultLogFormat;
+ mGroup->mFormat->formatSpec = DefaultLogFormat;
}
}
LoggerGeneralConfigurationPtr mGroup;
diff --git a/server/src/LoggingServer.cpp b/server/src/LoggingServer.cpp
index 00ef8d9..f4493a7 100644
--- a/server/src/LoggingServer.cpp
+++ b/server/src/LoggingServer.cpp
@@ -77,12 +77,14 @@ void LoggingServerI::setLevel(const std::string& name, Level level)
}
}
-void LoggingServerI::logs(const std::string& name, Level level,
- const std::string& message, long pid, const std::string& hostname, const Ice::Current&)
+void LoggingServerI::logs(const std::string& name, Level level, const std::string& message,
+ const std::string& hostname, Ice::Long pid,
+ const std::string& componentCategory, const std::string& serviceId, const std::string& componentId,
+ const Ice::Current&)
{
if (isEnabledFor(name, level))
{
- std::string formattedMessage = mFormatter.formatMessage(message,name,level,pid,hostname);
+ std::string formattedMessage = mFormatter.formatMessage(message,name,level,hostname,pid,componentCategory, serviceId,componentId);
if (!mLogsOut.empty())
{
for (std::vector<boost::shared_ptr<ChainedLogOut> >::const_iterator i = mLogsOut.begin();
diff --git a/server/src/LoggingServer.h b/server/src/LoggingServer.h
index 9f36c9e..6a59976 100644
--- a/server/src/LoggingServer.h
+++ b/server/src/LoggingServer.h
@@ -65,8 +65,11 @@ class LoggingServerI : public LoggingServer
public:
ASTERISK_SCF_ICEBOX_EXPORT LoggingServerI();
- ASTERISK_SCF_ICEBOX_EXPORT void logs(const std::string&, Level,
- const std::string&, long pid, const std::string& hostname, const Ice::Current&);
+ ASTERISK_SCF_ICEBOX_EXPORT void logs(const std::string& name, Level, const std::string& msg,
+ const std::string& hostname, Ice::Long pid,
+ const std::string& componentCategory, const std::string& serviceId, const std::string& componentId,
+ const Ice::Current&);
+
Configuration getConfiguration(const Ice::Current&) const
{
return getConfiguration();
diff --git a/server/src/main.cpp b/server/src/main.cpp
index 40f616b..f4c5cf7 100644
--- a/server/src/main.cpp
+++ b/server/src/main.cpp
@@ -108,7 +108,6 @@ void LoggingService::start(const std::string&,
const Ice::CommunicatorPtr& communicator,
const Ice::StringSeq&)
{
- sleep(2);
setupDefaultProperties(communicator);
mAdapter = communicator->createObjectAdapter(AdapterName);
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index 2c45ea8..a53dcdd 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -18,8 +18,8 @@ asterisk_scf_component_add_file(LoggingConfigurationTest ConfigurationTest.cpp)
asterisk_scf_component_add_file(LoggingConfigurationTest LoggingConfigurationHelper.cpp)
asterisk_scf_component_add_file(LoggingConfigurationTest LoggingConfigurationHelper.h)
asterisk_scf_component_add_slice(LoggingConfigurationTest ../local-slice/LoggingConfigurationIf.ice)
-asterisk_scf_component_add_boost_libraries(LoggingConfigurationTest unit_test_framework)
+asterisk_scf_component_add_boost_libraries(LoggingConfigurationTest unit_test_framework system)
asterisk_scf_component_build_icebox(LoggingConfigurationTest)
-target_link_libraries(LoggingConfigurationTest asterisk-scf-api)
+target_link_libraries(LoggingConfigurationTest asterisk-scf-api logging-service-lib logging-client)
asterisk_scf_test_icebox(LoggingConfigurationTest server/config/testloggingserver.conf)
diff --git a/server/test/ConfigurationTest.cpp b/server/test/ConfigurationTest.cpp
index c6c6068..4df537b 100644
--- a/server/test/ConfigurationTest.cpp
+++ b/server/test/ConfigurationTest.cpp
@@ -21,6 +21,8 @@
#include <boost/test/debug.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/lexical_cast.hpp>
+#include <boost/asio/ip/host_name.hpp>
+#include <boost/interprocess/detail/os_thread_functions.hpp>
#include <Ice/Ice.h>
#include <IceBox/IceBox.h>
@@ -105,6 +107,7 @@ struct GlobalIceFixture
TestBed.communicator = Ice::initialize(initData);
TestBed.adapter = TestBed.communicator->createObjectAdapterWithEndpoints("LoggerTestAdapter", "default");
ConfiguredIceLoggerPtr mIceLogger = createIceLogger(TestBed.adapter);
+ mIceLogger->getLogger().setComponentInfo("TestComponentCategory", "default", "TestInstance");
getLoggerFactory().setLogOutput(mIceLogger->getLogger());
TestBed.adapter->activate();
@@ -268,11 +271,13 @@ BOOST_AUTO_TEST_CASE(SetFormat)
TestBed.confHelper->setFormat(std::string("$t{%Y%m%d %H:%M:%S}: $m: $n,$l"),serial++);
//time_t Now = time(0);
lg(Info) << "Informational message 3";
- //pid_t pid = getpid();
+ Ice::Long pid = (Ice::Long)boost::interprocess::detail::get_current_process_id();
// Set format to "logger_name : pid : msg_level : msg"
TestBed.confHelper->setFormat(std::string("$l : $p : $n : $m"),serial++);
std::string CurSourceInfo = SRCINFO(" (line=$l:function=$f:source=$sf)");
lg(Debug) << "Debug message" << CurSourceInfo;
+ TestBed.confHelper->setFormat(std::string("$t - $C:$S:$I: ($l) $m"), serial++);
+ lg(Info) << "Something else.";
TestBed.confHelper->removeLogOutFile(fileName);
TestBed.confHelper->removeLogOutFile(fileName2);
FileStatus status = checkConfiguredFile(TestBed.confHelper, fileName);
diff --git a/server/test/LoggingConfigurationHelper.cpp b/server/test/LoggingConfigurationHelper.cpp
index c2cd82e..756c084 100644
--- a/server/test/LoggingConfigurationHelper.cpp
+++ b/server/test/LoggingConfigurationHelper.cpp
@@ -117,7 +117,7 @@ void LoggingConfigurationHelper::setFormat(const std::string& fmtStr, int serial
ConfigurationGroupSeq groups;
LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
FormatItemPtr formatItem(new FormatItem);
- formatItem->fmtStr = fmtStr;
+ formatItem->formatSpec = fmtStr;
formatItem->serialNumber = serialNumber;
generalGroup->configurationItems.insert(make_pair(FormatItemName, formatItem));
groups.push_back(generalGroup);
@@ -130,7 +130,7 @@ void LoggingConfigurationHelper::unsetFormat(const std::string& fmtStr)
ConfigurationGroupSeq groups;
LoggerGeneralGroupPtr generalGroup(new LoggerGeneralGroup);
FormatItemPtr formatItem(new FormatItem);
- formatItem->fmtStr = fmtStr;
+ formatItem->formatSpec = fmtStr;
generalGroup->configurationItems.insert(make_pair(FormatItemName, formatItem));
groups.push_back(generalGroup);
mConfigPrx->removeConfigurationItems(groups);
commit fcee6e43a1a37489174e9bb25e60074044492b62
Merge: bb3701d cc9fca2
Author: Ken Hunt <ken.hunt at digium.com>
Date: Tue Jun 21 15:25:58 2011 -0500
Merge remote branch 'integ/logformat' into logformat
commit bb3701dc70706e14e7def66d8560f47b96eeacef
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Wed Jun 1 16:57:30 2011 -0500
More CMake script cleanup.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b137cfc..bc9bdf4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
asterisk_scf_project(Logger 3.4)
add_subdirectory(server)
-add_subdirectory(client) # For the client test directory.
+add_subdirectory(client)
# The client component is built here, so as to be able to add files
# from both src and include directories.
diff --git a/server/test/CMakeLists.txt b/server/test/CMakeLists.txt
index b70278a..2c45ea8 100644
--- a/server/test/CMakeLists.txt
+++ b/server/test/CMakeLists.txt
@@ -22,6 +22,4 @@ asterisk_scf_component_add_boost_libraries(LoggingConfigurationTest unit_test_fr
asterisk_scf_component_build_icebox(LoggingConfigurationTest)
target_link_libraries(LoggingConfigurationTest asterisk-scf-api)
-if(integrated_build STREQUAL "true")
- asterisk_scf_test_icebox(LoggingConfigurationTest server/config/testloggingserver.conf)
-endif()
+asterisk_scf_test_icebox(LoggingConfigurationTest server/config/testloggingserver.conf)
commit 1d64744c3d255ffae0447d3c157e2bda220eb560
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Wed Jun 1 11:24:34 2011 -0500
Avoid subtle semantic error calling asterisk_scf_headers_install(). This
function should probably be improved to avoid this situation.
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 73e4990..b137cfc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,6 @@ asterisk_scf_component_build_library(logging-client)
target_link_libraries(logging-client asterisk-scf-api)
asterisk_scf_component_install(logging-client)
-asterisk_scf_headers_install(include)
+asterisk_scf_headers_install(include/)
set(logger_dir ${CMAKE_CURRENT_SOURCE_DIR} PARENT_SCOPE)
-----------------------------------------------------------------------
--
asterisk-scf/integration/logger.git
More information about the asterisk-scf-commits
mailing list