Skip to content

Commit

Permalink
update log messages
Browse files Browse the repository at this point in the history
  • Loading branch information
tekezo committed Oct 19, 2018
1 parent 10ef0df commit 1c03ff7
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 18 deletions.
2 changes: 1 addition & 1 deletion src/share/hid_manager.hpp
Expand Up @@ -70,7 +70,7 @@ class hid_manager final : public pqrs::dispatcher::extra::dispatcher_client {

manager_ = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
if (!manager_) {
logger::get_logger().error("{0}: failed to IOHIDManagerCreate", __PRETTY_FUNCTION__);
logger::get_logger().error("IOHIDManagerCreate is failed.");
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/share/human_interface_device.hpp
Expand Up @@ -179,7 +179,7 @@ class human_interface_device final : pqrs::dispatcher::extra::dispatcher_client
const CFIndex depth = 1024;
queue_ = IOHIDQueueCreate(kCFAllocatorDefault, device_, depth, kIOHIDOptionsTypeNone);
if (!queue_) {
logger::get_logger().error("IOHIDQueueCreate error @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().error("IOHIDQueueCreate is failed.");
} else {
// Add elements into queue_.
for (const auto& e : elements_) {
Expand Down
15 changes: 10 additions & 5 deletions src/share/iopm_client.hpp
Expand Up @@ -4,6 +4,7 @@

#include "cf_utility.hpp"
#include "dispatcher.hpp"
#include "iokit_utility.hpp"
#include "logger.hpp"
#include <IOKit/IOKitLib.h>
#include <IOKit/IOMessage.h>
Expand Down Expand Up @@ -61,7 +62,7 @@ class iopm_client final : public pqrs::dispatcher::extra::dispatcher_client {
static_callback,
&notifier_);
if (connect == MACH_PORT_NULL) {
logger::get_logger().error("IORegisterForSystemPower error @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().error("IORegisterForSystemPower is failed.");
return;
}

Expand All @@ -77,7 +78,8 @@ class iopm_client final : public pqrs::dispatcher::extra::dispatcher_client {
if (notifier_) {
auto kr = IODeregisterForSystemPower(&notifier_);
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IODeregisterForSystemPower error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IODeregisterForSystemPower is failed: {0}",
iokit_utility::get_error_name(kr));
}
notifier_ = IO_OBJECT_NULL;
}
Expand All @@ -90,7 +92,8 @@ class iopm_client final : public pqrs::dispatcher::extra::dispatcher_client {
if (connect_) {
auto kr = IOServiceClose(connect_);
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IOServiceClose error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IOServiceClose is failed: {0}",
iokit_utility::get_error_name(kr));
}
connect_ = IO_OBJECT_NULL;
}
Expand All @@ -110,7 +113,8 @@ class iopm_client final : public pqrs::dispatcher::extra::dispatcher_client {
if (connect_) {
auto kr = IOAllowPowerChange(connect_, reinterpret_cast<intptr_t>(message_argument));
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IOAllowPowerChange error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IOAllowPowerChange is failed: {0}",
iokit_utility::get_error_name(kr));
}
}
break;
Expand All @@ -128,7 +132,8 @@ class iopm_client final : public pqrs::dispatcher::extra::dispatcher_client {
if (connect_) {
auto kr = IOAllowPowerChange(connect_, reinterpret_cast<intptr_t>(message_argument));
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IOAllowPowerChange error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IOAllowPowerChange is failed: {0}",
iokit_utility::get_error_name(kr));
}
}
break;
Expand Down
4 changes: 2 additions & 2 deletions src/share/monitor/file_monitor.hpp
Expand Up @@ -132,13 +132,13 @@ class file_monitor final : public pqrs::dispatcher::extra::dispatcher_client {
0.1, // 100 ms
flags);
if (!stream_) {
logger::get_logger().error("FSEventStreamCreate error @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().error("FSEventStreamCreate is failed.");
} else {
FSEventStreamScheduleWithRunLoop(stream_,
run_loop_thread_->get_run_loop(),
kCFRunLoopCommonModes);
if (!FSEventStreamStart(stream_)) {
logger::get_logger().error("FSEventStreamStart error @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().error("FSEventStreamStart is failed.");
}

run_loop_thread_->wake();
Expand Down
14 changes: 9 additions & 5 deletions src/share/monitor/service_monitor/monitor.hpp
Expand Up @@ -3,6 +3,7 @@
#include "boost_defs.hpp"

#include "dispatcher.hpp"
#include "iokit_utility.hpp"
#include "logger.hpp"
#include "services.hpp"
#include <boost/signals2.hpp>
Expand Down Expand Up @@ -59,7 +60,8 @@ class monitor final : pqrs::dispatcher::extra::dispatcher_client {
io_iterator_t it;
auto kr = IOServiceGetMatchingServices(kIOMasterPortDefault, matching_dictionary_, &it);
if (kr != KERN_SUCCESS) {
logger::get_logger().error("IOServiceGetMatchingServices error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IOServiceGetMatchingServices is failed: {0}",
iokit_utility::get_error_name(kr));
} else {
matched_callback(it);
IOObjectRelease(it);
Expand All @@ -74,14 +76,14 @@ class monitor final : pqrs::dispatcher::extra::dispatcher_client {
if (!notification_port_) {
notification_port_ = IONotificationPortCreate(kIOMasterPortDefault);
if (!notification_port_) {
logger::get_logger().error("IONotificationPortCreate is failed @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().error("IONotificationPortCreate is failed.");
return;
}

if (auto loop_source = IONotificationPortGetRunLoopSource(notification_port_)) {
CFRunLoopAddSource(CFRunLoopGetMain(), loop_source, kCFRunLoopCommonModes);
} else {
logger::get_logger().error("IONotificationPortGetRunLoopSource is failed @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().error("IONotificationPortGetRunLoopSource is failed.");
}
}

Expand All @@ -97,7 +99,8 @@ class monitor final : pqrs::dispatcher::extra::dispatcher_client {
static_cast<void*>(this),
&matched_notification_);
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IOServiceAddMatchingNotification error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IOServiceAddMatchingNotification is failed: {0}",
iokit_utility::get_error_name(kr));
CFRelease(matching_dictionary_);
} else {
matched_callback(matched_notification_);
Expand All @@ -117,7 +120,8 @@ class monitor final : pqrs::dispatcher::extra::dispatcher_client {
static_cast<void*>(this),
&terminated_notification_);
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IOServiceAddMatchingNotification error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("IOServiceAddMatchingNotification is failed: {0}",
iokit_utility::get_error_name(kr));
CFRelease(matching_dictionary_);
} else {
terminated_callback(terminated_notification_);
Expand Down
10 changes: 6 additions & 4 deletions src/share/virtual_hid_device_client.hpp
Expand Up @@ -214,7 +214,7 @@ class virtual_hid_device_client final : public pqrs::dispatcher::extra::dispatch

auto kr = IOServiceOpen(service_, mach_task_self(), kIOHIDServerConnectType, &connect_);
if (kr == KERN_SUCCESS) {
logger::get_logger().info("IOServiceOpen is succeeded @ {0}", __PRETTY_FUNCTION__);
logger::get_logger().info("virtual_hid_device_client is opened.");

connected_ = true;

Expand All @@ -223,7 +223,8 @@ class virtual_hid_device_client final : public pqrs::dispatcher::extra::dispatch
});

} else {
logger::get_logger().error("IOServiceOpen error: {1} ({2}) @ {0}", __PRETTY_FUNCTION__, iokit_utility::get_error_name(kr), kr);
logger::get_logger().error("virtual_hid_device_client::open_connection is failed: {0}",
iokit_utility::get_error_name(kr));
connect_ = IO_OBJECT_NULL;
}
}
Expand All @@ -233,7 +234,8 @@ class virtual_hid_device_client final : public pqrs::dispatcher::extra::dispatch
if (connect_) {
auto kr = IOServiceClose(connect_);
if (kr != kIOReturnSuccess) {
logger::get_logger().error("IOConnectRelease error: {1} @ {0}", __PRETTY_FUNCTION__, kr);
logger::get_logger().error("virtual_hid_device_client::close_connection error: {0}",
iokit_utility::get_error_name(kr));
}
connect_ = IO_OBJECT_NULL;

Expand All @@ -243,7 +245,7 @@ class virtual_hid_device_client final : public pqrs::dispatcher::extra::dispatch
client_disconnected();
});

logger::get_logger().info("virtual_hid_device_client connection is closed.");
logger::get_logger().info("virtual_hid_device_client is closed.");
}

if (service_) {
Expand Down

0 comments on commit 1c03ff7

Please sign in to comment.