g_core = reinterpret_cast<const XW_CoreInterface*>(
get_interface(XW_CORE_INTERFACE));
if (!g_core) {
- std::cerr << "Can't initialize extension: error getting Core interface.\n";
+ LoggerE("Can't initialize extension: error getting Core interface.");
return false;
}
g_messaging = reinterpret_cast<const XW_MessagingInterface*>(
get_interface(XW_MESSAGING_INTERFACE));
if (!g_messaging) {
- std::cerr <<
- "Can't initialize extension: error getting Messaging interface.\n";
+ LoggerE("Can't initialize extension: error getting Messaging interface.");
return false;
}
reinterpret_cast<const XW_Internal_SyncMessagingInterface*>(
get_interface(XW_INTERNAL_SYNC_MESSAGING_INTERFACE));
if (!g_sync_messaging) {
- std::cerr <<
- "Can't initialize extension: error getting SyncMessaging interface.\n";
+ LoggerE("Can't initialize extension: error getting SyncMessaging interface.");
return false;
}
g_entry_points = reinterpret_cast<const XW_Internal_EntryPointsInterface*>(
get_interface(XW_INTERNAL_ENTRY_POINTS_INTERFACE));
if (!g_entry_points) {
- std::cerr << "NOTE: Entry points interface not available in this version "
- << "of runtime, ignoring entry point data for extensions.\n";
+ LoggerE("NOTE: Entry points interface not available in this version "
+ "of runtime, ignoring entry point data for extensions.");
}
g_runtime = reinterpret_cast<const XW_Internal_RuntimeInterface*>(
get_interface(XW_INTERNAL_RUNTIME_INTERFACE));
if (!g_runtime) {
- std::cerr << "NOTE: runtime interface not available in this version "
- << "of runtime, ignoring runtime variables for extensions.\n";
+ LoggerE("NOTE: runtime interface not available in this version "
+ "of runtime, ignoring runtime variables for extensions.");
}
g_permission = reinterpret_cast<const XW_Internal_PermissionsInterface*>(
get_interface(XW_INTERNAL_PERMISSIONS_INTERFACE));
if (!g_permission) {
- std::cerr << "NOTE: permission interface not available in this version "
- << "of runtime, ignoring permission for extensions.\n";
+ LoggerE("NOTE: permission interface not available in this version "
+ "of runtime, ignoring permission for extensions.");
}
g_data = reinterpret_cast<const XW_Internal_DataInterface*>(
get_interface(XW_INTERNAL_DATA_INTERFACE));
if (!g_data) {
- std::cerr << "NOTE: data interface not available in this version of "
- << "runtime, ignoring data for extensions.\n";
+ LoggerE("NOTE: data interface not available in this version of "
+ "runtime, ignoring data for extensions.");
}
initialized = true;
void Instance::PostMessage(const char* msg) {
LoggerD("Enter");
if (!xw_instance_) {
- std::cerr << "Ignoring PostMessage() in the constructor or after the "
- << "instance was destroyed.";
+ LoggerE("Ignoring PostMessage() in the constructor or after the "
+ "instance was destroyed.");
return;
}
g_messaging->PostMessage(xw_instance_, msg);
void Instance::PostData(const char* msg, uint8_t* buffer, size_t len) {
LoggerD("Enter");
if (!xw_instance_) {
- std::cerr << "Ignoring PostData() in the constructor or after the "
- << "instance was destroyed.";
+ LoggerE("Ignoring PostData() in the constructor or after the "
+ "instance was destroyed.");
return;
}
g_data->PostData(xw_instance_, msg, buffer, len);
void Instance::SendSyncReply(const char* reply) {
LoggerD("Enter");
if (!xw_instance_) {
- std::cerr << "Ignoring SendSyncReply() in the constructor or after the "
- << "instance was destroyed.";
+ LoggerE("Ignoring SendSyncReply() in the constructor or after the "
+ "instance was destroyed.");
return;
}
g_sync_messaging->SetSyncReply(xw_instance_, reply);
void Instance::SendSyncReply(const char* reply, uint8_t* buffer, size_t len) {
LoggerD("Enter");
if (!xw_instance_) {
- std::cerr << "Ignoring SendSyncReply() in the constructor or after the "
- << "instance was destroyed.";
+ LoggerE("Ignoring SendSyncReply() in the constructor or after the "
+ "instance was destroyed.");
return;
}
g_data->SetSyncReply(xw_instance_, reply, buffer, len);
std::string err;
picojson::parse(value, msg, msg + strlen(msg), &err);
if (!err.empty()) {
- std::cerr << "Ignoring message. " << err;
+ LoggerE("Ignoring message, error: %s", err.c_str());
return;
}
if (!value.is<picojson::object>()) {
- std::cerr << "Ignoring message. It is not an object.";
+ LoggerE("Ignoring message. It is not an object.");
return;
}
void ParsedInstance::HandleException(const PlatformException& ex) {
LoggerD("Enter");
- std::cerr << "Exception: " << ex.message();
+ LoggerE("Exception: %s", ex.message().c_str());
picojson::value result = picojson::value(picojson::object());
ReportError(ex, result.get<picojson::object>());
SendSyncReply(result.serialize().c_str());
std::string err;
picojson::parse(value_, msg, msg + strlen(msg), &err);
if (!err.empty()) {
- std::cerr << "Ignoring message. " << err;
+ LoggerE("Ignoring message, error: %s", err.c_str());
return false;
}
if (!value_.is<picojson::object>()) {
- std::cerr << "Ignoring message. It is not an object.";
+ LoggerE("Ignoring message. It is not an object.");
return false;
}