diff options
author | Jose <jose@zeroc.com> | 2019-05-29 22:08:27 +0200 |
---|---|---|
committer | Jose <jose@zeroc.com> | 2019-05-29 22:08:27 +0200 |
commit | fe9cf41fd22316fedd218aea56cd27f286fe09ec (patch) | |
tree | 67a6e69ceb9dc27c76df02518c0bf767ad361d4a /cpp/src/Ice/OSLogLoggerI.cpp | |
parent | Fix makeprops script (diff) | |
download | ice-fe9cf41fd22316fedd218aea56cd27f286fe09ec.tar.bz2 ice-fe9cf41fd22316fedd218aea56cd27f286fe09ec.tar.xz ice-fe9cf41fd22316fedd218aea56cd27f286fe09ec.zip |
Swift logger updates
Diffstat (limited to 'cpp/src/Ice/OSLogLoggerI.cpp')
-rw-r--r-- | cpp/src/Ice/OSLogLoggerI.cpp | 57 |
1 files changed, 57 insertions, 0 deletions
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 |