summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/Instance.cpp21
-rw-r--r--cpp/src/Ice/OSLogLoggerI.cpp57
-rw-r--r--cpp/src/Ice/OSLogLoggerI.h40
-rw-r--r--cpp/src/Ice/PropertyNames.cpp3
-rw-r--r--cpp/src/Ice/PropertyNames.h2
5 files changed, 118 insertions, 5 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp
index 8d448ee0ddb..0420d7cb7c2 100644
--- a/cpp/src/Ice/Instance.cpp
+++ b/cpp/src/Ice/Instance.cpp
@@ -51,6 +51,10 @@
#include <stdio.h>
#include <list>
+#ifdef __APPLE__
+# include <Ice/OSLogLoggerI.h>
+#endif
+
#ifndef _WIN32
# include <Ice/SysLoggerI.h>
# include <Ice/SystemdJournalI.h>
@@ -1096,13 +1100,24 @@ IceInternal::Instance::Instance(const CommunicatorPtr& communicator, const Initi
_initData.properties->getProperty("Ice.ProgramName"),
_initData.properties->getPropertyWithDefault("Ice.SyslogFacility", "LOG_USER"));
}
-# ifdef ICE_USE_SYSTEMD
- else if(_initData.properties->getPropertyAsInt("Ice.UseSystemdJournal") > 0)
+ else
+#endif
+
+#ifdef __APPLE__
+ if(!_initData.logger && _initData.properties->getPropertyAsInt("Ice.UseOSLog") > 0)
+ {
+ _initData.logger = ICE_MAKE_SHARED(OSLogLoggerI,
+ _initData.properties->getProperty("Ice.ProgramName"));
+ }
+ else
+#endif
+
+#ifdef ICE_USE_SYSTEMD
+ if(_initData.properties->getPropertyAsInt("Ice.UseSystemdJournal") > 0)
{
_initData.logger = ICE_MAKE_SHARED(SystemdJournalI,
_initData.properties->getProperty("Ice.ProgramName"));
}
-# endif
else
#endif
if(!logfile.empty())
diff --git a/cpp/src/Ice/OSLogLoggerI.cpp b/cpp/src/Ice/OSLogLoggerI.cpp
new file mode 100644
index 00000000000..262c8144306
--- /dev/null
+++ b/cpp/src/Ice/OSLogLoggerI.cpp
@@ -0,0 +1,57 @@
+//
+// Copyright (c) ZeroC, Inc. All rights reserved.
+//
+
+#ifdef __APPLE__
+
+#include <Ice/OSLogLoggerI.h>
+#include <os/log.h>
+
+using namespace std;
+using namespace Ice;
+
+Ice::OSLogLoggerI::OSLogLoggerI(const std::string& prefix) : _prefix(prefix)
+{
+ const string subsystem = prefix.empty() ? "com.zeroc.ice" : "com.zeroc.ice." + prefix;
+ _log.reset(os_log_create(subsystem.c_str(), ""));
+}
+
+void
+Ice::OSLogLoggerI::print(const std::string& message)
+{
+ os_log_with_type(_log.get(), OS_LOG_TYPE_DEFAULT, "%{public}s.", message.c_str());
+}
+
+void
+Ice::OSLogLoggerI::trace(const std::string& category, const std::string& message)
+{
+ const string subsystem = _prefix.empty() ? "com.zeroc.ice" : "com.zeroc.ice." + _prefix;
+ IceInternal::UniqueRef<os_log_t> log(os_log_create(subsystem.c_str(), category.c_str()));
+ os_log_with_type(log.get(), OS_LOG_TYPE_INFO, "%{public}s.", message.c_str());
+}
+
+void
+Ice::OSLogLoggerI::warning(const std::string& message)
+{
+ os_log_with_type(_log.get(), OS_LOG_TYPE_ERROR, "%{public}s.", message.c_str());
+}
+
+void
+Ice::OSLogLoggerI::error(const std::string& message)
+{
+ os_log_with_type(_log.get(), OS_LOG_TYPE_FAULT, "%{public}s.", message.c_str());
+}
+
+std::string
+Ice::OSLogLoggerI::getPrefix()
+{
+ return _prefix;
+}
+
+LoggerPtr
+Ice::OSLogLoggerI::cloneWithPrefix(const std::string& prefix)
+{
+ return ICE_MAKE_SHARED(OSLogLoggerI, prefix);
+}
+
+#endif
diff --git a/cpp/src/Ice/OSLogLoggerI.h b/cpp/src/Ice/OSLogLoggerI.h
new file mode 100644
index 00000000000..917d9bad4d5
--- /dev/null
+++ b/cpp/src/Ice/OSLogLoggerI.h
@@ -0,0 +1,40 @@
+//
+// Copyright (c) ZeroC, Inc. All rights reserved.
+//
+
+#ifndef ICE_OSLOG_LOGGER_I_H
+#define ICE_OSLOG_LOGGER_I_H
+
+#ifdef __APPLE__
+
+#include <Ice/Logger.h>
+#include <Ice/UniqueRef.h>
+#include <os/log.h>
+
+namespace Ice
+{
+
+class OSLogLoggerI : public Logger
+{
+public:
+
+ OSLogLoggerI(const std::string&);
+
+ virtual void print(const std::string&);
+ virtual void trace(const std::string&, const std::string&);
+ virtual void warning(const std::string&);
+ virtual void error(const std::string&);
+ virtual std::string getPrefix();
+ virtual LoggerPtr cloneWithPrefix(const std::string&);
+
+private:
+
+ const std::string _prefix;
+ IceInternal::UniqueRef<os_log_t> _log;
+};
+
+}
+
+#endif
+
+#endif
diff --git a/cpp/src/Ice/PropertyNames.cpp b/cpp/src/Ice/PropertyNames.cpp
index fc3b319e828..c33836e8ea6 100644
--- a/cpp/src/Ice/PropertyNames.cpp
+++ b/cpp/src/Ice/PropertyNames.cpp
@@ -1,7 +1,7 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Thu Oct 25 22:10:11 2018
+// Generated by makeprops.py from file ../config/PropertyNames.xml, Wed May 29 21:06:31 2019
// IMPORTANT: Do not edit this file -- any edits made here will be lost!
@@ -175,6 +175,7 @@ const IceInternal::Property IcePropsData[] =
IceInternal::Property("Ice.TCP.RcvSize", false, 0),
IceInternal::Property("Ice.TCP.SndSize", false, 0),
IceInternal::Property("Ice.UseApplicationClassLoader", false, 0),
+ IceInternal::Property("Ice.UseOSLog", false, 0),
IceInternal::Property("Ice.UseSyslog", false, 0),
IceInternal::Property("Ice.UseSystemdJournal", false, 0),
IceInternal::Property("Ice.Warn.AMICallback", false, 0),
diff --git a/cpp/src/Ice/PropertyNames.h b/cpp/src/Ice/PropertyNames.h
index a820f58a7ad..b4b83cf22f3 100644
--- a/cpp/src/Ice/PropertyNames.h
+++ b/cpp/src/Ice/PropertyNames.h
@@ -1,7 +1,7 @@
//
// Copyright (c) ZeroC, Inc. All rights reserved.
//
-// Generated by makeprops.py from file ../config/PropertyNames.xml, Thu Oct 25 22:10:11 2018
+// Generated by makeprops.py from file ../config/PropertyNames.xml, Wed May 29 21:06:31 2019
// IMPORTANT: Do not edit this file -- any edits made here will be lost!