From 219adba5ce60fe5839bfac0b21b1f02bf9630d2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ali=20R=C4=B1za=20Kat?= Date: Sat, 3 Aug 2024 05:31:31 +0300 Subject: [PATCH 1/2] Updating Logs --- examples/example_integration.cpp | 4 +- include/countly.hpp | 2 +- src/countly.cpp | 141 ++++++++++++++++--------------- 3 files changed, 74 insertions(+), 73 deletions(-) diff --git a/examples/example_integration.cpp b/examples/example_integration.cpp index e8306aa..5481c74 100644 --- a/examples/example_integration.cpp +++ b/examples/example_integration.cpp @@ -51,7 +51,7 @@ int main() { string _serverUrl = "https://your.server.ly"; if(_appKey.compare("YOUR_APP_KEY") == 0 || _serverUrl.compare("https://your.server.ly") == 0) { - cerr << "Please do not use default set of app key and server url" << endl; + printLog(LogLevel::WARNING, "[ExampleIntegration] Please do not use default set of app key and server url"); } ct.start(_appKey, _serverUrl, 443, true); @@ -164,7 +164,7 @@ int main() { flag = false; break; default: - cout << "Option not found!" << endl; + printLog(LogLevel::DEBUG, "[ExampleIntegration] Please do not use default set of app key and server url"); break; } } diff --git a/include/countly.hpp b/include/countly.hpp index 9c95583..66f26e1 100644 --- a/include/countly.hpp +++ b/include/countly.hpp @@ -251,7 +251,7 @@ class Countly : public cly::CountlyDelegates { /* Provide 'updateInterval' in seconds. */ inline void setAutomaticSessionUpdateInterval(unsigned short updateInterval) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setAutomaticSessionUpdateInterval] You can not set the session duration after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setAutomaticSessionUpdateInterval, You can not set the session duration after SDK initialization."); return; } diff --git a/src/countly.cpp b/src/countly.cpp index bb2188f..0b1df50 100644 --- a/src/countly.cpp +++ b/src/countly.cpp @@ -53,7 +53,7 @@ void Countly::halt() { _sharedInstance.reset(new Countly()); } */ void Countly::setMaxRequestQueueSize(unsigned int requestQueueSize) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setMaxRequestQueueSize] You can not set the request queue size after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setMaxRequestQueueSize, This method can't be called after SDK initialization. Returning."); return; } @@ -75,7 +75,7 @@ void Countly::setMaxRQProcessingBatchSize(unsigned int batchSize) { void Countly::alwaysUsePost(bool value) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][alwaysUsePost] You can not set the http method after SDK initialization."); + log(LogLevel::WARNING, "[Countly]alwaysUsePost, This method can't be called after SDK initialization. Returning."); return; } @@ -86,7 +86,7 @@ void Countly::alwaysUsePost(bool value) { void Countly::setSalt(const std::string &value) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setSalt] You can not set the salt after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setSalt, This method can't be called after SDK initialization. Returning."); return; } @@ -97,7 +97,7 @@ void Countly::setSalt(const std::string &value) { void Countly::setLogger(void (*fun)(LogLevel level, const std::string &message)) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setLogger] You can not set the logger after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setLogger, This method can't be called after SDK initialization. Returning."); return; } @@ -108,7 +108,7 @@ void Countly::setLogger(void (*fun)(LogLevel level, const std::string &message)) void Countly::setHTTPClient(HTTPClientFunction fun) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setHTTPClient] You can not set the http client after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setHTTPClient, This method can't be called after SDK initialization. Returning."); return; } @@ -119,7 +119,7 @@ void Countly::setHTTPClient(HTTPClientFunction fun) { void Countly::setSha256(SHA256Function fun) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setHTTPClient] You can not set the 'SHA256' function after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setSha256, This method can't be called after SDK initialization. Returning."); return; } @@ -130,7 +130,7 @@ void Countly::setSha256(SHA256Function fun) { void Countly::setMetrics(const std::string &os, const std::string &os_version, const std::string &device, const std::string &resolution, const std::string &carrier, const std::string &app_version) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setMetrics] You can not set metrics after SDK initialization."); + log(LogLevel::WARNING, "[Countly]setMetrics, This method can't be called after SDK initialization. Returning."); return; } @@ -163,7 +163,7 @@ void Countly::setUserDetails(const std::map &value) { session_params["user_details"] = value; if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly][setUserDetails] Can not send user detail if the SDK has not been initialized."); + log(LogLevel::ERROR, "[Countly]setUserDetails, This method can't be called before SDK initialization. Returning."); mutex->unlock(); return; } @@ -179,7 +179,7 @@ void Countly::setCustomUserDetails(const std::map &val session_params["user_details"]["custom"] = value; if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly][setCustomUserDetails] Can not send user detail if the SDK has not been initialized."); + log(LogLevel::ERROR, "[Countly]setCustomUserDetails, This method can't be called before SDK initialization. Returning."); mutex->unlock(); return; } @@ -212,10 +212,10 @@ void Countly::setLocation(double lattitude, double longitude) { void Countly::setLocation(const std::string &countryCode, const std::string &city, const std::string &gpsCoordinates, const std::string &ipAddress) { mutex->lock(); - log(LogLevel::INFO, "[Countly][setLocation] SetLocation : countryCode = " + countryCode + ", city = " + city + ", gpsCoordinates = " + gpsCoordinates + ", ipAddress = " + ipAddress); + log(LogLevel::INFO, "[Countly]setLocation, Setting location as: countryCode = [" + countryCode + "], city = [" + city + "], gpsCoordinates = [" + gpsCoordinates + "], ipAddress = [" + ipAddress + "]"); if ((!countryCode.empty() && city.empty()) || (!city.empty() && countryCode.empty())) { - log(LogLevel::WARNING, "[Countly][setLocation] In \"SetLocation\" both country code and city should be set together"); + log(LogLevel::WARNING, "[Countly]setLocation, It's required that both 'country_code' and 'city' should be set together"); } session_params["city"] = city; @@ -232,7 +232,7 @@ void Countly::setLocation(const std::string &countryCode, const std::string &cit void Countly::_sendIndependantLocationRequest() { mutex->lock(); - log(LogLevel::DEBUG, "[Countly] [_sendIndependantLocationRequest]"); + log(LogLevel::DEBUG, "[Countly]_sendIndependantLocationRequest, Start"); /* * Empty country code, city and IP address can not be sent. @@ -275,25 +275,25 @@ void Countly::_sendIndependantLocationRequest() { void Countly::setDeviceID(const std::string &value, bool same_user) { mutex->lock(); configuration->deviceId = value; - log(LogLevel::INFO, "[Countly][changeDeviceIdWithMerge] setDeviceID = '" + value + "'"); + log(LogLevel::INFO, "[Countly]setDeviceID, Setting device id as = [" + value + "]"); // Checking old and new devices ids are same if (session_params.contains("device_id") && session_params["device_id"].get() == value) { - log(LogLevel::DEBUG, "[Countly][setDeviceID] new device id and old device id are same."); + log(LogLevel::DEBUG, "[Countly]setDeviceID, Provided device id and the current device id are same. Returning."); mutex->unlock(); return; } if (!session_params.contains("device_id")) { session_params["device_id"] = value; - log(LogLevel::DEBUG, "[Countly][setDeviceID] no device was set, setting device id"); + log(LogLevel::DEBUG, "[Countly]setDeviceID, No device was set, setting device id as [" + value + "]"); mutex->unlock(); return; } mutex->unlock(); if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly][setDeviceID] Can not change the device id if the SDK has not been initialized."); + log(LogLevel::ERROR, "[Countly]setDeviceID, Device id can't be changed while the SDK has not been initialized."); return; } @@ -307,7 +307,7 @@ void Countly::setDeviceID(const std::string &value, bool same_user) { /* Change device ID with merge after SDK has been initialized.*/ void Countly::_changeDeviceIdWithMerge(const std::string &value) { mutex->lock(); - log(LogLevel::DEBUG, "[Countly][changeDeviceIdWithMerge] deviceId = '" + value + "'"); + log(LogLevel::DEBUG, "[Countly]_changeDeviceIdWithMerge, deviceId = [" + value + "]"); session_params["old_device_id"] = session_params["device_id"]; session_params["device_id"] = value; @@ -328,7 +328,7 @@ void Countly::_changeDeviceIdWithMerge(const std::string &value) { /* Change device ID without merge after SDK has been initialized.*/ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) { - log(LogLevel::DEBUG, "[Countly][changeDeviceIdWithoutMerge] deviceId = '" + value + "'"); + log(LogLevel::DEBUG, "[Countly]changeDeviceIdWithoutMerge, deviceId = [" + value + "]"); // send all event to server and end current session of old user flushEvents(); @@ -349,49 +349,49 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) { void Countly::start(const std::string &app_key, const std::string &host, int port, bool start_thread) { mutex->lock(); if (is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly][start] SDK has already been initialized, 'start' should not be called a second time!"); + log(LogLevel::ERROR, "[Countly]start, SDK has already been initialized, 'start' should not be called a second time!"); mutex->unlock(); return; } #ifdef COUNTLY_USE_SQLITE if (configuration->databasePath == "" || configuration->databasePath == " ") { - log(LogLevel::ERROR, "[Countly][start] Database path can not be empty or blank."); + log(LogLevel::ERROR, "[Countly]start, Database path can not be empty or blank. Returning."); return; } #endif - log(LogLevel::INFO, "[Countly][start]"); + log(LogLevel::INFO, "[Countly]start"); #ifdef COUNTLY_USE_SQLITE - log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_SQLITE' is defined"); + log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_SQLITE' is defined"); #else - log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_SQLITE' is not defined"); + log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_SQLITE' is not defined"); #endif #ifdef COUNTLY_USE_CUSTOM_HTTP - log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_HTTP' is defined"); + log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_HTTP' is defined"); #else - log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_HTTP' is not defined"); + log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_HTTP' is not defined"); #endif #ifdef COUNTLY_USE_CUSTOM_SHA256 - log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_SHA256' is defined"); + log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_SHA256' is defined"); #else - log(LogLevel::INFO, "[Countly][start] 'COUNTLY_USE_CUSTOM_SHA256' is not defined"); + log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_SHA256' is not defined"); #endif #ifdef _WIN32 - log(LogLevel::INFO, "[Countly][start] '_WIN32' is defined"); + log(LogLevel::INFO, "[Countly]start, '_WIN32' is defined"); #else - log(LogLevel::INFO, "[Countly][start] '_WIN32' is not defined"); + log(LogLevel::INFO, "[Countly]start, '_WIN32' is not defined"); #endif enable_automatic_session = start_thread; start_thread = true; if (port < 0 || port > 65535) { - log(LogLevel::WARNING, "[Countly][start] Port number is out of valid boundaries. Setting it to 0."); + log(LogLevel::WARNING, "[Countly]start, Port number is out of valid boundaries. Setting it to 0."); port = 0; } @@ -433,7 +433,7 @@ void Countly::start(const std::string &app_key, const std::string &host, int por thread.reset(new std::thread(&Countly::updateLoop, this)); } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "Could not create thread: " << e.what(); + log_message << "[Countly]start, Could not create thread: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -464,7 +464,7 @@ void Countly::_deleteThread() { try { thread->join(); } catch (const std::system_error &e) { - log(LogLevel::WARNING, "Could not join thread"); + log(LogLevel::WARNING, "[Countly]_deleteThread, Could not join thread"); } thread.reset(); } @@ -493,7 +493,7 @@ void Countly::checkAndSendEventToRQ() { mutex->lock(); #ifdef COUNTLY_USE_SQLITE if (queueSize >= configuration->eventQueueThreshold) { - log(LogLevel::DEBUG, "Event queue threshold is reached"); + log(LogLevel::DEBUG, "[Countly]checkAndSendEventToRQ, Event queue threshold is reached"); std::string event_ids; // fetch events up to the threshold from the database @@ -507,7 +507,7 @@ void Countly::checkAndSendEventToRQ() { } #else if (queueSize >= configuration->eventQueueThreshold) { - log(LogLevel::WARNING, "Event queue is full, dropping the oldest event to insert a new one"); + log(LogLevel::WARNING, "[Countly]checkAndSendEventToRQ, Event queue is full, dropping the oldest event to insert a new one"); for (const auto &event_json : event_queue) { events.push_back(nlohmann::json::parse(event_json)); } @@ -524,13 +524,13 @@ void Countly::setMaxEvents(size_t value) { } void Countly::setEventsToRQThreshold(int value) { - log(LogLevel::DEBUG, "[Countly][setEventsToRQThreshold] Given threshold:[" + std::to_string(value) + "]"); + log(LogLevel::DEBUG, "[Countly]setEventsToRQThreshold, Given threshold:[" + std::to_string(value) + "]"); mutex->lock(); if (value < 1) { - log(LogLevel::WARNING, "[Countly][setEventsToRQThreshold] Threshold can not be less than 1. Setting it to 1 instead of:[" + std::to_string(value) + "]"); + log(LogLevel::WARNING, "[Countly]setEventsToRQThreshold, Threshold can not be less than 1. Setting it to 1 instead of:[" + std::to_string(value) + "]"); value = 1; } else if (value > 10000) { - log(LogLevel::WARNING, "[Countly][setEventsToRQThreshold] Threshold can not be greater than 10000. Setting it to 10000 instead of:[" + std::to_string(value) + "]"); + log(LogLevel::WARNING, "[Countly]setEventsToRQThreshold, Threshold can not be greater than 10000. Setting it to 10000 instead of:[" + std::to_string(value) + "]"); value = 10000; } @@ -542,7 +542,7 @@ void Countly::setEventsToRQThreshold(int value) { } void Countly::flushEvents(std::chrono::seconds timeout) { - log(LogLevel::DEBUG, "[Countly][flushEvents] timeout: " + std::to_string(timeout.count()) + " seconds"); + log(LogLevel::DEBUG, "[Countly]flushEvents, timeout: [" + std::to_string(timeout.count()) + "] seconds"); try { auto wait_duration = std::chrono::seconds(1); @@ -573,7 +573,7 @@ void Countly::flushEvents(std::chrono::seconds timeout) { // TODO: Check if we capture anything other than a system_error } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "flushEvents, error: " << e.what(); + log_message << "[Countly]flushEvents, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -645,7 +645,7 @@ std::vector Countly::debugReturnStateOfEQ() { return v; } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "debugReturnStateOfEQ, error: " << e.what(); + log_message << "[Countly]debugReturnStateOfEQ, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -653,7 +653,7 @@ std::vector Countly::debugReturnStateOfEQ() { bool Countly::beginSession() { mutex->lock(); - log(LogLevel::INFO, "[Countly][beginSession]"); + log(LogLevel::INFO, "[Countly]beginSession, Start"); if (began_session) { mutex->unlock(); return true; @@ -712,6 +712,7 @@ bool Countly::updateSession() { if (!began_session) { mutex->unlock(); if (!beginSession()) { + log(LogLevel::DEBUG, "[Countly]updateSession, Failed to begin session."); // if beginSession fails, we should not try to update session return false; } @@ -738,7 +739,7 @@ bool Countly::updateSession() { mutex->lock(); #endif } else { - log(LogLevel::DEBUG, "[Countly][updateSession] EQ empty."); + log(LogLevel::DEBUG, "[Countly]updateSession, EQ empty."); } mutex->unlock(); auto duration = std::chrono::duration_cast(getSessionDuration()); @@ -746,7 +747,7 @@ bool Countly::updateSession() { // report session duration if it is greater than the configured session duration value if (duration.count() >= configuration->sessionDuration) { - log(LogLevel::DEBUG, "[Countly][updateSession] sending session update."); + log(LogLevel::DEBUG, "[Countly]updateSession, Sending session update."); std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"session_duration", std::to_string(duration.count())}}; requestModule->addRequestToQueue(data); @@ -770,7 +771,7 @@ bool Countly::updateSession() { #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "update session, error: " << e.what(); + log_message << "[Countly]updateSession, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } mutex->unlock(); @@ -778,13 +779,13 @@ bool Countly::updateSession() { } void Countly::sendEventsToRQ(const nlohmann::json &events) { - log(LogLevel::DEBUG, "[Countly][sendEventsToRQ] Sending events to RQ."); + log(LogLevel::DEBUG, "[Countly]sendEventsToRQ, Sending events to RQ."); std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"events", events.dump()}}; requestModule->addRequestToQueue(data); } bool Countly::endSession() { - log(LogLevel::INFO, "[Countly][endSession]"); + log(LogLevel::INFO, "[Countly]endSession, Start"); const std::chrono::system_clock::time_point now = Countly::getTimestamp(); const auto timestamp = std::chrono::duration_cast(now.time_since_epoch()); const auto duration = std::chrono::duration_cast(getSessionDuration(now)); @@ -809,10 +810,10 @@ bool Countly::endSession() { std::chrono::system_clock::time_point Countly::getTimestamp() { return std::chrono::system_clock::now(); } int Countly::checkEQSize() { - log(LogLevel::DEBUG, "[Countly][checkEQSize]"); + log(LogLevel::DEBUG, "[Countly]checkEQSize, Start"); int event_count = -1; if (!is_sdk_initialized) { - log(LogLevel::DEBUG, "[Countly][checkEQSize] SDK is not initialized."); + log(LogLevel::DEBUG, "[Countly]checkEQSize, This method can't be called before SDK initialization."); return event_count; } @@ -826,7 +827,7 @@ int Countly::checkEQSize() { #ifndef COUNTLY_USE_SQLITE int Countly::checkMemoryEQSize() { - log(LogLevel::DEBUG, "[Countly][checkMemoryEQSize] Checking event queue size in memory"); + log(LogLevel::DEBUG, "[Countly]checkMemoryEQSize, Checking event queue size in memory."); int result = 0; mutex->lock(); result = event_queue.size(); @@ -839,7 +840,7 @@ int Countly::checkMemoryEQSize() { #ifdef COUNTLY_USE_SQLITE void Countly::removeEventWithId(const std::string &event_ids) { // TODO: Check if we should check database_path set or not - log(LogLevel::DEBUG, "[Countly][removeEventWithId] Removing events from storage: " + event_ids); + log(LogLevel::DEBUG, "[Countly]removeEventWithId, Removing events from storage: [" + event_ids + "]"); sqlite3 *database; int return_value; char *error_message; @@ -856,10 +857,10 @@ void Countly::removeEventWithId(const std::string &event_ids) { log(LogLevel::ERROR, error_message); sqlite3_free(error_message); } else { - log(LogLevel::DEBUG, "[Countly][removeEventWithId] Removed events with the given ID(s)."); + log(LogLevel::DEBUG, "[Countly]removeEventWithId, Removed events with the given ID(s)."); } } else { - log(LogLevel::ERROR, "[Countly][removeEventWithId] Could not open database."); + log(LogLevel::ERROR, "[Countly]removeEventWithId, Could not open database."); } sqlite3_close(database); } @@ -868,12 +869,12 @@ void Countly::fillEventsIntoJson(nlohmann::json &events, std::string &event_ids) mutex->lock(); if (database_path.empty()) { mutex->unlock(); - log(LogLevel::FATAL, "[Countly][fillEventsIntoJson] Sqlite database path is not set."); + log(LogLevel::FATAL, "[Countly]fillEventsIntoJson, SQLite database path is not set."); event_ids = ""; return; } - log(LogLevel::DEBUG, "[Countly][fillEventsIntoJson] Fetching events from storage."); + log(LogLevel::DEBUG, "[Countly]fillEventsIntoJson, Fetching events from storage."); sqlite3 *database; int return_value, row_count, column_count; char **table; @@ -900,7 +901,7 @@ void Countly::fillEventsIntoJson(nlohmann::json &events, std::string &event_ids) events.push_back(nlohmann::json::parse(table[(event_index * column_count) + 1])); } - log(LogLevel::DEBUG, "[Countly][fillEventsIntoJson] Events count = " + std::to_string(events.size())); + log(LogLevel::DEBUG, "[Countly]fillEventsIntoJson, Events count = [" + std::to_string(events.size()) + "]"); event_id_stream.seekp(-1, event_id_stream.cur); event_id_stream << ')'; @@ -913,7 +914,7 @@ void Countly::fillEventsIntoJson(nlohmann::json &events, std::string &event_ids) } sqlite3_free_table(table); } else { - log(LogLevel::ERROR, "[Countly][fillEventsIntoJson] Could not open database."); + log(LogLevel::ERROR, "[Countly]fillEventsIntoJson, Could not open database."); } sqlite3_close(database); mutex->unlock(); @@ -924,7 +925,7 @@ int Countly::checkPersistentEQSize() { mutex->lock(); if (database_path.empty()) { mutex->unlock(); - log(LogLevel::FATAL, "[Countly][checkEQSize] Sqlite database path is not set"); + log(LogLevel::FATAL, "[Countly]checkPersistentEQSize, SQLite database path is not set"); return result; } @@ -939,24 +940,24 @@ int Countly::checkPersistentEQSize() { return_value = sqlite3_get_table(database, "SELECT COUNT(*) FROM events;", &table, &row_count, &column_count, &error_message); if (return_value == SQLITE_OK) { result = atoi(table[1]); - log(LogLevel::DEBUG, "[Countly][checkEQSize] Fetched event count from database: " + std::to_string(result)); + log(LogLevel::DEBUG, "[Countly]checkPersistentEQSize, Fetched event count from database: [" + std::to_string(result) + "]"); } else { log(LogLevel::ERROR, error_message); sqlite3_free(error_message); } sqlite3_free_table(table); } else { - log(LogLevel::WARNING, "[Countly][checkEQSize] Could not open database"); + log(LogLevel::WARNING, "[Countly]checkPersistentEQSize, Could not open database"); } sqlite3_close(database); return result; } void Countly::addEventToSqlite(const cly::Event &event) { - log(LogLevel::DEBUG, "[Countly][addEventToSqlite]"); + log(LogLevel::DEBUG, "[Countly]addEventToSqlite, Start"); try { if (database_path.empty()) { - log(LogLevel::FATAL, "Cannot add event, sqlite database path is not set"); + log(LogLevel::FATAL, "[Countly]addEventToSqlite, Cannot add event, SQLite database path is not set"); return; } @@ -980,13 +981,13 @@ void Countly::addEventToSqlite(const cly::Event &event) { sqlite3_close(database); } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "addEventToSqlite, error: " << e.what(); + log_message << "[Countly]addEventToSqlite, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } void Countly::clearPersistentEQ() { - log(LogLevel::DEBUG, "[Countly][clearEQ]"); + log(LogLevel::DEBUG, "[Countly]clearPersistentEQ,"); sqlite3 *database; int return_value; char *error_message; @@ -998,7 +999,7 @@ void Countly::clearPersistentEQ() { log(LogLevel::FATAL, error_message); sqlite3_free(error_message); } else { - log(LogLevel::DEBUG, "[Countly][clearEQ] Cleared event queue"); + log(LogLevel::DEBUG, "[Countly]clearPersistentEQ, Cleared event queue"); } } sqlite3_close(database); @@ -1006,17 +1007,17 @@ void Countly::clearPersistentEQ() { void Countly::setDatabasePath(const std::string &path) { if (is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly][setDatabasePath] You can not set the database path after SDK initialization."); + log(LogLevel::ERROR, "[Countly]setDatabasePath, This method can't be called after SDK initialization. Returning."); return; } if (path == "" || path == " ") { - log(LogLevel::ERROR, "[Countly][setDatabasePath] Database path can not be empty or blank."); + log(LogLevel::ERROR, "[Countly]setDatabasePath, Database path can not be empty or blank. Returning"); return; } configuration->databasePath = path; - log(LogLevel::INFO, "[Countly][setDatabasePath] path = " + path); + log(LogLevel::INFO, "[Countly]setDatabasePath, Setting database path = [" + path + "]"); } bool Countly::createEventTableSchema() { @@ -1064,7 +1065,7 @@ std::string Countly::calculateChecksum(const std::string &salt, const std::strin std::string salted_data = data + salt; #ifdef COUNTLY_USE_CUSTOM_SHA256 if (configuration->sha256_function == nullptr) { - log(LogLevel::FATAL, "Missing SHA 256 function"); + log(LogLevel::FATAL, "[Countly]calculateChecksum, Missing SHA 256 function"); return {}; } @@ -1096,7 +1097,7 @@ std::chrono::system_clock::duration Countly::getSessionDuration(std::chrono::sys std::chrono::system_clock::duration Countly::getSessionDuration() { return Countly::getSessionDuration(Countly::getTimestamp()); } void Countly::updateLoop() { - log(LogLevel::DEBUG, "[Countly][updateLoop]"); + log(LogLevel::DEBUG, "[Countly]updateLoop, Start"); mutex->lock(); running = true; mutex->unlock(); @@ -1139,7 +1140,7 @@ void Countly::updateRemoteConfig() { mutex->lock(); if (!session_params["app_key"].is_string() || !session_params["device_id"].is_string()) { - log(LogLevel::ERROR, "Error updating remote config, app key or device id is missing"); + log(LogLevel::ERROR, "[Countly]updateLoop, Error updating remote config, app key or device id is missing"); mutex->unlock(); return; } From 7f175ddbdc933452749381f54505a96b025097ae Mon Sep 17 00:00:00 2001 From: Arif Burak Demiray Date: Thu, 16 Apr 2026 15:23:17 +0300 Subject: [PATCH 2/2] feat: update logs --- src/configuration_module.cpp | 24 ++-- src/countly.cpp | 218 +++++++++++++++++----------------- src/crash_module.cpp | 18 +-- src/request_module.cpp | 38 +++--- src/storage_module_db.cpp | 112 ++++++++--------- src/storage_module_memory.cpp | 36 +++--- src/views_module.cpp | 34 +++--- 7 files changed, 240 insertions(+), 240 deletions(-) diff --git a/src/configuration_module.cpp b/src/configuration_module.cpp index 5db660c..883106d 100644 --- a/src/configuration_module.cpp +++ b/src/configuration_module.cpp @@ -147,19 +147,19 @@ class ConfigurationModule::ConfigurationModuleImpl { sanitizeConfig(response.data[KEY_CONFIG]); sdk_behavior_settings = response.data[KEY_CONFIG]; _storageModule->storeSDKBehaviorSettings(sdk_behavior_settings.dump()); - _logger->log(LogLevel::INFO, "[ConfigurationModule] _fetchConfigFromServerHTTP, SDK config:\n" + sdk_behavior_settings.dump(2)); + _logger->log(LogLevel::INFO, "[Countly] [ConfigurationModule] _fetchConfigFromServerHTTP, SDK config:\n" + sdk_behavior_settings.dump(2)); changedSettings = _populateConfigValues(); } _onSBSChanged(changedSettings, session_params); } else { _logger->log(LogLevel::WARNING, - "[ConfigurationModule] _fetchConfigFromServerHTTP, failed to fetch." + "[Countly] [ConfigurationModule] _fetchConfigFromServerHTTP, failed to fetch." " success=" + std::string(response.success ? "true" : "false") + ", is_object=" + std::string(response.data.is_object() ? "true" : "false") + ", has_config=" + std::string((response.data.is_object() && response.data.contains(KEY_CONFIG)) ? "true" : "false") + ", response=" + response.data.dump()); } } catch (const std::exception &e) { - _logger->log(LogLevel::ERROR, "[ConfigurationModule] _fetchConfigFromServerHTTP, exception: " + std::string(e.what())); + _logger->log(LogLevel::ERROR, "[Countly] [ConfigurationModule] _fetchConfigFromServerHTTP, exception: [" + std::string(e.what()) + "]"); } } @@ -169,13 +169,13 @@ class ConfigurationModule::ConfigurationModuleImpl { std::string sbs_string = _storageModule->getSDKBehaviorSettings(); if (!sbs_string.empty()) { nlohmann::json changed = _processSDKBehaviorSettings(sbs_string); - _logger->log(LogLevel::INFO, "[ConfigurationModule] _initializeSBSFromStorage, initialized SDK behavior settings from storage."); + _logger->log(LogLevel::INFO, "[Countly] [ConfigurationModule] _initializeSBSFromStorage, initialized SDK behavior settings from storage."); return changed; } else if (!_configuration->sdkBehaviorSettings.empty()) { nlohmann::json changed = _processSDKBehaviorSettings(_configuration->sdkBehaviorSettings); // Persist the provided SBS so it's available on future re-inits _storageModule->storeSDKBehaviorSettings(sdk_behavior_settings.dump()); - _logger->log(LogLevel::INFO, "[ConfigurationModule] _initializeSBSFromStorage, initialized SDK behavior settings from configuration."); + _logger->log(LogLevel::INFO, "[Countly] [ConfigurationModule] _initializeSBSFromStorage, initialized SDK behavior settings from configuration."); return changed; } return nlohmann::json{}; @@ -192,10 +192,10 @@ class ConfigurationModule::ConfigurationModuleImpl { nlohmann::json sbs_json = nlohmann::json::parse(settings); sanitizeConfig(sbs_json); sdk_behavior_settings = sbs_json; - _logger->log(LogLevel::INFO, "[ConfigurationModule] _processSDKBehaviorSettings, SDK config:\n" + sdk_behavior_settings.dump(2)); + _logger->log(LogLevel::INFO, "[Countly] [ConfigurationModule] _processSDKBehaviorSettings, SDK config:\n" + sdk_behavior_settings.dump(2)); return _populateConfigValues(); } catch (const nlohmann::json::parse_error &e) { - _logger->log(LogLevel::ERROR, "[ConfigurationModule] _processSDKBehaviorSettings, Failed to parse SDK behavior settings: " + std::string(e.what())); + _logger->log(LogLevel::ERROR, "[Countly] [ConfigurationModule] _processSDKBehaviorSettings, Failed to parse SDK behavior settings: [" + std::string(e.what()) + "]"); return nlohmann::json{}; } } @@ -308,7 +308,7 @@ class ConfigurationModule::ConfigurationModuleImpl { continue; } } else { - _logger->log(LogLevel::DEBUG, "[ConfigurationModule] sanitizeConfig, removing unknown key: " + key); + _logger->log(LogLevel::DEBUG, "[Countly] [ConfigurationModule] sanitizeConfig, removing unknown key: [" + key + "]"); it = c.erase(it); continue; } @@ -348,7 +348,7 @@ class ConfigurationModule::ConfigurationModuleImpl { _fetchConfigFromServerHTTP(data, session_params); lock.lock(); } catch (const std::exception &e) { - _logger->log(LogLevel::ERROR, "[ConfigurationModule] _updateConfigPeriodically, exception: " + std::string(e.what())); + _logger->log(LogLevel::ERROR, "[Countly] [ConfigurationModule] _updateConfigPeriodically, exception: [" + std::string(e.what()) + "]"); if (!lock.owns_lock()) { lock.lock(); } @@ -357,7 +357,7 @@ class ConfigurationModule::ConfigurationModuleImpl { } void _stopTimer() { - _logger->log(LogLevel::WARNING, "[ConfigurationModule] stopTimer, stopping server config update timer thread."); + _logger->log(LogLevel::WARNING, "[Countly] [ConfigurationModule] stopTimer, stopping server config update timer thread."); stopConfigThread.store(true, std::memory_order_release); configUpdateCv.notify_all(); @@ -368,7 +368,7 @@ class ConfigurationModule::ConfigurationModuleImpl { void _startTimer(nlohmann::json session_params) { if (_configuration->sdkBehaviorSettingsUpdatesDisabled) { - _logger->log(LogLevel::INFO, "[ConfigurationModule] _startTimer, SDK behavior settings updates are disabled."); + _logger->log(LogLevel::INFO, "[Countly] [ConfigurationModule] _startTimer, SDK behavior settings updates are disabled."); return; } @@ -422,7 +422,7 @@ class ConfigurationModule::ConfigurationModuleImpl { ConfigurationModule::ConfigurationModule(cly::CountlyDelegates *cly, std::shared_ptr config, std::shared_ptr logger, std::shared_ptr requestBuilder, std::shared_ptr storageModule, std::shared_ptr requestModule, std::shared_ptr mutex) { impl.reset(new ConfigurationModuleImpl(cly, config, logger, requestBuilder, storageModule, requestModule, mutex)); - impl->_logger->log(LogLevel::DEBUG, "[ConfigurationModule] Initialized"); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [ConfigurationModule] Initialized"); } ConfigurationModule::~ConfigurationModule() { impl.reset(); } diff --git a/src/countly.cpp b/src/countly.cpp index 7b8357f..c3f31bb 100644 --- a/src/countly.cpp +++ b/src/countly.cpp @@ -54,7 +54,7 @@ void Countly::halt() { _sharedInstance.reset(new Countly()); } */ void Countly::setMaxRequestQueueSize(unsigned int requestQueueSize) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]setMaxRequestQueueSize, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] setMaxRequestQueueSize, This method can't be called after SDK initialization. Returning."); return; } @@ -76,7 +76,7 @@ void Countly::setMaxRQProcessingBatchSize(unsigned int batchSize) { void Countly::alwaysUsePost(bool value) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]alwaysUsePost, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] alwaysUsePost, This method can't be called after SDK initialization. Returning."); return; } @@ -87,7 +87,7 @@ void Countly::alwaysUsePost(bool value) { void Countly::setSalt(const std::string &value) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]setSalt, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] setSalt, This method can't be called after SDK initialization. Returning."); return; } @@ -98,7 +98,7 @@ void Countly::setSalt(const std::string &value) { void Countly::setLogger(void (*fun)(LogLevel level, const std::string &message)) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]setLogger, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] setLogger, This method can't be called after SDK initialization. Returning."); return; } @@ -109,7 +109,7 @@ void Countly::setLogger(void (*fun)(LogLevel level, const std::string &message)) void Countly::setHTTPClient(HTTPClientFunction fun) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]setHTTPClient, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] setHTTPClient, This method can't be called after SDK initialization. Returning."); return; } @@ -120,7 +120,7 @@ void Countly::setHTTPClient(HTTPClientFunction fun) { void Countly::setSha256(SHA256Function fun) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]setSha256, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] setSha256, This method can't be called after SDK initialization. Returning."); return; } @@ -134,7 +134,7 @@ void Countly::setSha256(SHA256Function fun) { */ void Countly::enableManualSessionControl() { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][enableManualSessionControl] You can not enable manual session control after SDK initialization."); + log(LogLevel::WARNING, "[Countly] enableManualSessionControl, You can not enable manual session control after SDK initialization."); return; } @@ -148,7 +148,7 @@ void Countly::enableManualSessionControl() { */ void Countly::disableAutoEventsOnUserProperties() { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][disableAutoEventsOnUserProperties] You can not disable automatic events on user properties after SDK initialization."); + log(LogLevel::WARNING, "[Countly] disableAutoEventsOnUserProperties, You can not disable automatic events on user properties after SDK initialization."); return; } @@ -159,7 +159,7 @@ void Countly::disableAutoEventsOnUserProperties() { void Countly::setMetrics(const std::string &os, const std::string &os_version, const std::string &device, const std::string &resolution, const std::string &carrier, const std::string &app_version) { if (is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly]setMetrics, This method can't be called after SDK initialization. Returning."); + log(LogLevel::WARNING, "[Countly] setMetrics, This method can't be called after SDK initialization. Returning."); return; } @@ -192,7 +192,7 @@ void Countly::setUserDetails(const std::map &value) { session_params["user_details"] = value; if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly]setUserDetails, This method can't be called before SDK initialization. Returning."); + log(LogLevel::ERROR, "[Countly] setUserDetails, This method can't be called before SDK initialization. Returning."); mutex->unlock(); return; } @@ -230,7 +230,7 @@ void Countly::setCustomUserDetails(const std::map &val } if (filteredValue.empty()) { - log(LogLevel::DEBUG, "[Countly][setCustomUserDetails] All user properties were filtered out by SBS user property filter."); + log(LogLevel::DEBUG, "[Countly] setCustomUserDetails, All user properties were filtered out by SBS user property filter."); mutex->unlock(); return; } @@ -243,7 +243,7 @@ void Countly::setCustomUserDetails(const std::map &val } if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly]setCustomUserDetails, This method can't be called before SDK initialization. Returning."); + log(LogLevel::ERROR, "[Countly] setCustomUserDetails, This method can't be called before SDK initialization. Returning."); mutex->unlock(); return; } @@ -263,17 +263,17 @@ void Countly::setCustomUserDetails(const std::map &val #pragma region User location void Countly::setCountry(const std::string &country_code) { - log(LogLevel::WARNING, "[Countly][setCountry] 'setCountry' is deprecated, please use 'setLocation(countryCode, city, gpsCoordinates, ipAddress)' method instead."); + log(LogLevel::WARNING, "[Countly] setCountry, 'setCountry' is deprecated, please use 'setLocation(countryCode, city, gpsCoordinates, ipAddress)' method instead."); setLocation(country_code, "", "", ""); } void Countly::setCity(const std::string &city_name) { - log(LogLevel::WARNING, "[Countly][setCity] 'setCity' is deprecated, please use 'setLocation(countryCode, city, gpsCoordinates, ipAddress)' method instead."); + log(LogLevel::WARNING, "[Countly] setCity, 'setCity' is deprecated, please use 'setLocation(countryCode, city, gpsCoordinates, ipAddress)' method instead."); setLocation("", city_name, "", ""); } void Countly::setLocation(double lattitude, double longitude) { - log(LogLevel::WARNING, "[Countly][setLocation] 'setLocation(latitude, longitude)' is deprecated, please use 'setLocation(countryCode, city, gpsCoordinates, ipAddress)' method instead."); + log(LogLevel::WARNING, "[Countly] setLocation, 'setLocation(latitude, longitude)' is deprecated, please use 'setLocation(countryCode, city, gpsCoordinates, ipAddress)' method instead."); std::ostringstream location_stream; location_stream << lattitude << ',' << longitude; @@ -282,20 +282,20 @@ void Countly::setLocation(double lattitude, double longitude) { void Countly::setLocation(const std::string &countryCode, const std::string &city, const std::string &gpsCoordinates, const std::string &ipAddress) { if (!is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][setLocation] SDK is not initialized."); + log(LogLevel::WARNING, "[Countly] setLocation, SDK is not initialized."); return; } bool isClearingLocation = countryCode.empty() && city.empty() && gpsCoordinates.empty() && ipAddress.empty(); mutex->lock(); if (!isClearingLocation && configurationModule->isLocationTrackingEnabled() == false) { - log(LogLevel::ERROR, "[Countly][setLocation] Location tracking is disabled in server configuration, can not set location."); + log(LogLevel::ERROR, "[Countly] setLocation, Location tracking is disabled in server configuration, can not set location."); mutex->unlock(); return; } - log(LogLevel::INFO, "[Countly][setLocation] SetLocation : countryCode = " + countryCode + ", city = " + city + ", gpsCoordinates = " + gpsCoordinates + ", ipAddress = " + ipAddress); + log(LogLevel::INFO, "[Countly] setLocation, Setting location: countryCode = [" + countryCode + "], city = [" + city + "], gpsCoordinates = [" + gpsCoordinates + "], ipAddress = [" + ipAddress + "]"); if ((!countryCode.empty() && city.empty()) || (!city.empty() && countryCode.empty())) { - log(LogLevel::WARNING, "[Countly]setLocation, It's required that both 'country_code' and 'city' should be set together"); + log(LogLevel::WARNING, "[Countly] setLocation, It's required that both 'country_code' and 'city' should be set together"); } session_params["city"] = city; @@ -312,7 +312,7 @@ void Countly::setLocation(const std::string &countryCode, const std::string &cit void Countly::_sendIndependantLocationRequest() { mutex->lock(); - log(LogLevel::DEBUG, "[Countly]_sendIndependantLocationRequest, Start"); + log(LogLevel::DEBUG, "[Countly] _sendIndependantLocationRequest, Start"); /* * Empty country code, city and IP address can not be sent. @@ -358,25 +358,25 @@ void Countly::_sendIndependantLocationRequest() { #pragma region Device Id void Countly::setDeviceID(const std::string &value, bool same_user) { mutex->lock(); - log(LogLevel::INFO, "[Countly][setDeviceID] setDeviceID requested = '" + value + "'"); + log(LogLevel::INFO, "[Countly] setDeviceID, Device ID change requested, new value = [" + value + "]"); if (!session_params.contains("device_id")) { session_params["device_id"] = value; configuration->deviceId = value; - log(LogLevel::DEBUG, "[Countly][setDeviceID] no previous device id, assigning initial device id"); + log(LogLevel::DEBUG, "[Countly] setDeviceID, No previous device id, assigning initial device id"); mutex->unlock(); return; } if (session_params["device_id"].get() == value) { - log(LogLevel::DEBUG, "[Countly][setDeviceID] new device id equals existing device id, ignoring."); + log(LogLevel::DEBUG, "[Countly] setDeviceID, New device id equals existing device id, ignoring."); mutex->unlock(); return; } mutex->unlock(); if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly]setDeviceID, Device id can't be changed while the SDK has not been initialized."); + log(LogLevel::ERROR, "[Countly] setDeviceID, Device id can't be changed while the SDK has not been initialized."); return; } @@ -390,7 +390,7 @@ void Countly::setDeviceID(const std::string &value, bool same_user) { /* Change device ID with merge after SDK has been initialized.*/ void Countly::_changeDeviceIdWithMerge(const std::string &value) { mutex->lock(); - log(LogLevel::DEBUG, "[Countly]_changeDeviceIdWithMerge, deviceId = [" + value + "]"); + log(LogLevel::DEBUG, "[Countly] _changeDeviceIdWithMerge, deviceId = [" + value + "]"); session_params["old_device_id"] = session_params["device_id"]; session_params["device_id"] = value; @@ -411,7 +411,7 @@ void Countly::_changeDeviceIdWithMerge(const std::string &value) { } void Countly::_changeDeviceIdWithoutMerge(const std::string &value) { - log(LogLevel::DEBUG, "[Countly]changeDeviceIdWithoutMerge, deviceId = [" + value + "]"); + log(LogLevel::DEBUG, "[Countly] _changeDeviceIdWithoutMerge, deviceId = [" + value + "]"); // send all event to server and end current session of old user flushEvents(); @@ -434,50 +434,50 @@ void Countly::_changeDeviceIdWithoutMerge(const std::string &value) { void Countly::start(const std::string &app_key, const std::string &host, int port, bool start_thread) { mutex->lock(); if (is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly]start, SDK has already been initialized, 'start' should not be called a second time!"); + log(LogLevel::ERROR, "[Countly] start, SDK has already been initialized, 'start' should not be called a second time!"); mutex->unlock(); return; } #ifdef COUNTLY_USE_SQLITE if (configuration->databasePath == "" || configuration->databasePath == " ") { - log(LogLevel::ERROR, "[Countly][start] Database path can not be empty or blank."); + log(LogLevel::ERROR, "[Countly] start, Database path can not be empty or blank."); mutex->unlock(); return; } #endif - log(LogLevel::INFO, "[Countly]start"); + log(LogLevel::INFO, "[Countly] start, Initializing SDK"); #ifdef COUNTLY_USE_SQLITE - log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_SQLITE' is defined"); + log(LogLevel::INFO, "[Countly] start, 'COUNTLY_USE_SQLITE' is defined"); #else - log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_SQLITE' is not defined"); + log(LogLevel::INFO, "[Countly] start, 'COUNTLY_USE_SQLITE' is not defined"); #endif #ifdef COUNTLY_USE_CUSTOM_HTTP - log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_HTTP' is defined"); + log(LogLevel::INFO, "[Countly] start, 'COUNTLY_USE_CUSTOM_HTTP' is defined"); #else - log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_HTTP' is not defined"); + log(LogLevel::INFO, "[Countly] start, 'COUNTLY_USE_CUSTOM_HTTP' is not defined"); #endif #ifdef COUNTLY_USE_CUSTOM_SHA256 - log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_SHA256' is defined"); + log(LogLevel::INFO, "[Countly] start, 'COUNTLY_USE_CUSTOM_SHA256' is defined"); #else - log(LogLevel::INFO, "[Countly]start, 'COUNTLY_USE_CUSTOM_SHA256' is not defined"); + log(LogLevel::INFO, "[Countly] start, 'COUNTLY_USE_CUSTOM_SHA256' is not defined"); #endif #ifdef _WIN32 - log(LogLevel::INFO, "[Countly]start, '_WIN32' is defined"); + log(LogLevel::INFO, "[Countly] start, '_WIN32' is defined"); #else - log(LogLevel::INFO, "[Countly]start, '_WIN32' is not defined"); + log(LogLevel::INFO, "[Countly] start, '_WIN32' is not defined"); #endif enable_automatic_session = start_thread; start_thread = true; if (port < 0 || port > 65535) { - log(LogLevel::WARNING, "[Countly]start, Port number is out of valid boundaries. Setting it to 0."); + log(LogLevel::WARNING, "[Countly] start, Port number is out of valid boundaries. Setting it to 0."); port = 0; } @@ -508,13 +508,13 @@ void Countly::start(const std::string &app_key, const std::string &host, int por #ifdef COUNTLY_USE_SQLITE result = createEventTableSchema(); if (!result) { - log(LogLevel::ERROR, "[Countly][start] Failed to initialize database at path: '" + configuration->databasePath + "'. SDK will not be initialized. Please verify the path is valid and writable."); + log(LogLevel::ERROR, "[Countly] start, Failed to initialize database at path: '" + configuration->databasePath + "'. SDK will not be initialized. Please verify the path is valid and writable."); } #endif is_sdk_initialized = result; // after this point SDK is initialized. if (!is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly][start] SDK initialization failed."); + log(LogLevel::ERROR, "[Countly] start, SDK initialization failed."); mutex->unlock(); return; } @@ -542,7 +542,7 @@ void Countly::start(const std::string &app_key, const std::string &host, int por thread.reset(new std::thread(&Countly::updateLoop, this)); } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "[Countly]start, Could not create thread: " << e.what(); + log_message << "[Countly] start, Could not create thread: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -554,7 +554,7 @@ void Countly::start(const std::string &app_key, const std::string &host, int por * startOnCloud is deprecated and this is going to be removed in the future. */ void Countly::startOnCloud(const std::string &app_key) { - log(LogLevel::WARNING, "[Countly][startOnCloud] 'startOnCloud' is deprecated, this is going to be removed in the future."); + log(LogLevel::WARNING, "[Countly] startOnCloud, 'startOnCloud' is deprecated, this is going to be removed in the future."); this->start(app_key, "https://cloud.count.ly", 443); } @@ -573,7 +573,7 @@ void Countly::_deleteThread() { try { thread->join(); } catch (const std::system_error &e) { - log(LogLevel::WARNING, "[Countly]_deleteThread, Could not join thread"); + log(LogLevel::WARNING, "[Countly] _deleteThread, Could not join thread"); } thread.reset(); } @@ -596,7 +596,7 @@ void Countly::addEvent(const cly::Event &event) { // Check custom event tracking (only blocks custom events) if (!configurationModule->isCustomEventTrackingEnabled() && !isInternalEvent) { - log(LogLevel::DEBUG, "[Countly] addEvent, custom event tracking is disabled in server configuration, can not add event with key: " + eventKey); + log(LogLevel::DEBUG, "[Countly] addEvent, custom event tracking is disabled in server configuration, can not add event with key: [" + eventKey + "]"); return; } @@ -611,7 +611,7 @@ void Countly::addEvent(const cly::Event &event) { blocked = (filter.filterList.find(eventKey) != filter.filterList.end()); } if (blocked) { - log(LogLevel::DEBUG, "[Countly] addEvent, event filtered out by SBS event filter: " + eventKey); + log(LogLevel::DEBUG, "[Countly] addEvent, event filtered out by SBS event filter: [" + eventKey + "]"); return; } } @@ -654,7 +654,7 @@ void Countly::addEvent(const cly::Event &event) { } } } catch (const std::exception &e) { - log(LogLevel::ERROR, "[Countly] addEvent, error applying segmentation filter: " + std::string(e.what())); + log(LogLevel::ERROR, "[Countly] addEvent, error applying segmentation filter: [" + std::string(e.what()) + "]"); } } @@ -678,7 +678,7 @@ void Countly::checkAndSendEventToRQ() { mutex->lock(); #ifdef COUNTLY_USE_SQLITE if (queueSize >= configurationModule->getEventQueueSizeLimit()) { - log(LogLevel::DEBUG, "Event queue threshold is reached"); + log(LogLevel::DEBUG, "[Countly] checkAndSendEventToRQ, Event queue threshold is reached"); std::string event_ids; // fetch events up to the threshold from the database @@ -692,7 +692,7 @@ void Countly::checkAndSendEventToRQ() { } #else if (queueSize >= configurationModule->getEventQueueSizeLimit()) { - log(LogLevel::WARNING, "Event queue is full, dropping the oldest event to insert a new one"); + log(LogLevel::WARNING, "[Countly] checkAndSendEventToRQ, Event queue is full, dropping the oldest event to insert a new one"); for (const auto &event_json : event_queue) { events.push_back(nlohmann::json::parse(event_json)); } @@ -704,18 +704,18 @@ void Countly::checkAndSendEventToRQ() { } void Countly::setMaxEvents(size_t value) { - log(LogLevel::WARNING, "[Countly][setMaxEvents/SetMaxEventsPerMessage] These calls are deprecated. Use 'setEventsToRQThreshold' instead."); + log(LogLevel::WARNING, "[Countly] setMaxEvents, 'setMaxEvents' and 'SetMaxEventsPerMessage' are deprecated. Use 'setEventsToRQThreshold' instead."); setEventsToRQThreshold(static_cast(value)); } void Countly::setEventsToRQThreshold(int value) { - log(LogLevel::DEBUG, "[Countly]setEventsToRQThreshold, Given threshold:[" + std::to_string(value) + "]"); + log(LogLevel::DEBUG, "[Countly] setEventsToRQThreshold, Given threshold:[" + std::to_string(value) + "]"); mutex->lock(); if (value < 1) { - log(LogLevel::WARNING, "[Countly]setEventsToRQThreshold, Threshold can not be less than 1. Setting it to 1 instead of:[" + std::to_string(value) + "]"); + log(LogLevel::WARNING, "[Countly] setEventsToRQThreshold, Threshold can not be less than 1. Setting it to 1 instead of:[" + std::to_string(value) + "]"); value = 1; } else if (value > 10000) { - log(LogLevel::WARNING, "[Countly]setEventsToRQThreshold, Threshold can not be greater than 10000. Setting it to 10000 instead of:[" + std::to_string(value) + "]"); + log(LogLevel::WARNING, "[Countly] setEventsToRQThreshold, Threshold can not be greater than 10000. Setting it to 10000 instead of:[" + std::to_string(value) + "]"); value = 10000; } @@ -727,7 +727,7 @@ void Countly::setEventsToRQThreshold(int value) { } void Countly::flushEvents(std::chrono::seconds timeout) { - log(LogLevel::DEBUG, "[Countly]flushEvents, timeout: [" + std::to_string(timeout.count()) + "] seconds"); + log(LogLevel::DEBUG, "[Countly] flushEvents, timeout: [" + std::to_string(timeout.count()) + "] seconds"); try { auto wait_duration = std::chrono::seconds(1); @@ -758,7 +758,7 @@ void Countly::flushEvents(std::chrono::seconds timeout) { // TODO: Check if we capture anything other than a system_error } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "[Countly]flushEvents, error: " << e.what(); + log_message << "[Countly] flushEvents, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -834,7 +834,7 @@ std::vector Countly::debugReturnStateOfEQ() { return v; } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "[Countly]debugReturnStateOfEQ, error: " << e.what(); + log_message << "[Countly] debugReturnStateOfEQ, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -842,19 +842,19 @@ std::vector Countly::debugReturnStateOfEQ() { bool Countly::beginSession() { if (!is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][beginSession] SDK is not initialized."); + log(LogLevel::WARNING, "[Countly] beginSession, SDK is not initialized."); return false; } mutex->lock(); - log(LogLevel::INFO, "[Countly][beginSession]"); + log(LogLevel::INFO, "[Countly] beginSession, Starting session"); if (configurationModule->isSessionTrackingEnabled() == false) { - log(LogLevel::ERROR, "[Countly][beginSession] Session tracking is disabled in server configuration, can not begin session."); + log(LogLevel::ERROR, "[Countly] beginSession, Session tracking is disabled in server configuration, can not begin session."); mutex->unlock(); return false; } if (began_session == true) { mutex->unlock(); - log(LogLevel::DEBUG, "[Countly][beginSession] Session is already active."); + log(LogLevel::DEBUG, "[Countly] beginSession, Session is already active."); return true; } @@ -906,25 +906,25 @@ bool Countly::beginSession() { */ bool Countly::updateSession() { if (!is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][updateSession] SDK is not initialized."); + log(LogLevel::WARNING, "[Countly] updateSession, SDK is not initialized."); return false; } try { // Check if there was a session, if not try to start one mutex->lock(); if (configurationModule->isSessionTrackingEnabled() == false) { - log(LogLevel::ERROR, "[Countly][updateSession] Session tracking is disabled in server configuration, can not update session."); + log(LogLevel::ERROR, "[Countly] updateSession, Session tracking is disabled in server configuration, can not update session."); mutex->unlock(); return false; } if (began_session == false) { mutex->unlock(); if (configuration->manualSessionControl == true) { - log(LogLevel::WARNING, "[Countly][updateSession] SDK is in manual session control mode and there is no active session. Please start a session first."); + log(LogLevel::WARNING, "[Countly] updateSession, SDK is in manual session control mode and there is no active session. Please start a session first."); return false; } if (!beginSession()) { - log(LogLevel::DEBUG, "[Countly]updateSession, Failed to begin session."); + log(LogLevel::DEBUG, "[Countly] updateSession, Failed to begin session."); // if beginSession fails, we should not try to update session return false; } @@ -951,7 +951,7 @@ bool Countly::updateSession() { mutex->lock(); #endif } else { - log(LogLevel::DEBUG, "[Countly]updateSession, EQ empty."); + log(LogLevel::DEBUG, "[Countly] updateSession, EQ empty."); } mutex->unlock(); auto duration = std::chrono::duration_cast(getSessionDuration()); @@ -959,7 +959,7 @@ bool Countly::updateSession() { // report session duration if it is greater than the configured session duration value if (duration.count() >= configurationModule->getSessionUpdateInterval()) { - log(LogLevel::DEBUG, "[Countly][updateSession] sending session update."); + log(LogLevel::DEBUG, "[Countly] updateSession, Sending session update."); std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"session_duration", std::to_string(duration.count())}}; requestModule->addRequestToQueue(data); @@ -983,7 +983,7 @@ bool Countly::updateSession() { #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "[Countly]updateSession, error: " << e.what(); + log_message << "[Countly] updateSession, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } mutex->unlock(); @@ -1012,7 +1012,7 @@ void Countly::packEvents() { mutex->lock(); #endif } else { - log(LogLevel::DEBUG, "[Countly][packEvents] EQ empty."); + log(LogLevel::DEBUG, "[Countly] packEvents, EQ empty."); } // report events if there are any to request queue if (!no_events) { @@ -1031,30 +1031,30 @@ void Countly::packEvents() { #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "packEvents, error: " << e.what(); + log_message << "[Countly] packEvents, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } mutex->unlock(); } void Countly::sendEventsToRQ(const nlohmann::json &events) { - log(LogLevel::DEBUG, "[Countly]sendEventsToRQ, Sending events to RQ."); + log(LogLevel::DEBUG, "[Countly] sendEventsToRQ, Sending events to RQ."); std::map data = {{"app_key", session_params["app_key"].get()}, {"device_id", session_params["device_id"].get()}, {"events", events.dump()}}; requestModule->addRequestToQueue(data); } bool Countly::endSession() { if (!is_sdk_initialized && !is_being_disposed) { - log(LogLevel::WARNING, "[Countly][endSession] SDK is not initialized."); + log(LogLevel::WARNING, "[Countly] endSession, SDK is not initialized."); return false; } - log(LogLevel::INFO, "[Countly][endSession]"); + log(LogLevel::INFO, "[Countly] endSession, Ending session"); if (is_being_disposed == false && configurationModule->isSessionTrackingEnabled() == false) { - log(LogLevel::ERROR, "[Countly][endSession] Session tracking is disabled in server configuration, can not end session."); + log(LogLevel::ERROR, "[Countly] endSession, Session tracking is disabled in server configuration, can not end session."); return false; } if (began_session == false) { - log(LogLevel::DEBUG, "[Countly][endSession] There is no active session to end."); + log(LogLevel::DEBUG, "[Countly] endSession, There is no active session to end."); return true; } const std::chrono::system_clock::time_point now = Countly::getTimestamp(); @@ -1081,10 +1081,10 @@ bool Countly::endSession() { std::chrono::system_clock::time_point Countly::getTimestamp() { return std::chrono::system_clock::now(); } int Countly::checkEQSize() { - log(LogLevel::DEBUG, "[Countly]checkEQSize, Start"); + log(LogLevel::DEBUG, "[Countly] checkEQSize, Start"); int event_count = -1; if (!is_sdk_initialized) { - log(LogLevel::DEBUG, "[Countly]checkEQSize, This method can't be called before SDK initialization."); + log(LogLevel::DEBUG, "[Countly] checkEQSize, This method can't be called before SDK initialization."); return event_count; } @@ -1097,10 +1097,10 @@ int Countly::checkEQSize() { } int Countly::checkRQSize() { - log(LogLevel::DEBUG, "[Countly][checkRQSize]"); + log(LogLevel::DEBUG, "[Countly] checkRQSize, Start"); int request_count = -1; if (!is_sdk_initialized) { - log(LogLevel::DEBUG, "[Countly][checkRQSize] SDK is not initialized."); + log(LogLevel::DEBUG, "[Countly] checkRQSize, SDK is not initialized."); return request_count; } @@ -1110,7 +1110,7 @@ int Countly::checkRQSize() { #ifndef COUNTLY_USE_SQLITE int Countly::checkMemoryEQSize() { - log(LogLevel::DEBUG, "[Countly]checkMemoryEQSize, Checking event queue size in memory."); + log(LogLevel::DEBUG, "[Countly] checkMemoryEQSize, Checking event queue size in memory."); int result = 0; mutex->lock(); result = static_cast(event_queue.size()); @@ -1123,7 +1123,7 @@ int Countly::checkMemoryEQSize() { #ifdef COUNTLY_USE_SQLITE void Countly::removeEventWithId(const std::string &event_ids) { // TODO: Check if we should check database_path set or not - log(LogLevel::DEBUG, "[Countly]removeEventWithId, Removing events from storage: [" + event_ids + "]"); + log(LogLevel::DEBUG, "[Countly] removeEventWithId, Removing events from storage: [" + event_ids + "]"); sqlite3 *database; int return_value; char *error_message; @@ -1137,13 +1137,13 @@ void Countly::removeEventWithId(const std::string &event_ids) { return_value = sqlite3_exec(database, sql_statement.c_str(), nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { - log(LogLevel::ERROR, error_message); + log(LogLevel::ERROR, "[Countly] removeEventWithId, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } else { - log(LogLevel::DEBUG, "[Countly]removeEventWithId, Removed events with the given ID(s)."); + log(LogLevel::DEBUG, "[Countly] removeEventWithId, Removed events with the given ID(s)."); } } else { - log(LogLevel::ERROR, "[Countly]removeEventWithId, Could not open database."); + log(LogLevel::ERROR, "[Countly] removeEventWithId, Could not open database."); } sqlite3_close(database); } @@ -1152,12 +1152,12 @@ void Countly::fillEventsIntoJson(nlohmann::json &events, std::string &event_ids) mutex->lock(); if (database_path.empty()) { mutex->unlock(); - log(LogLevel::FATAL, "[Countly]fillEventsIntoJson, SQLite database path is not set."); + log(LogLevel::FATAL, "[Countly] fillEventsIntoJson, SQLite database path is not set."); event_ids = ""; return; } - log(LogLevel::DEBUG, "[Countly]fillEventsIntoJson, Fetching events from storage."); + log(LogLevel::DEBUG, "[Countly] fillEventsIntoJson, Fetching events from storage."); sqlite3 *database; int return_value, row_count, column_count; char **table; @@ -1184,7 +1184,7 @@ void Countly::fillEventsIntoJson(nlohmann::json &events, std::string &event_ids) events.push_back(nlohmann::json::parse(table[(event_index * column_count) + 1])); } - log(LogLevel::DEBUG, "[Countly]fillEventsIntoJson, Events count = [" + std::to_string(events.size()) + "]"); + log(LogLevel::DEBUG, "[Countly] fillEventsIntoJson, Events count = [" + std::to_string(events.size()) + "]"); event_id_stream.seekp(-1, event_id_stream.cur); event_id_stream << ')'; @@ -1192,12 +1192,12 @@ void Countly::fillEventsIntoJson(nlohmann::json &events, std::string &event_ids) // write event ids to a string stream (or more like copy out that stream here) to be used in the delete statement event_ids = event_id_stream.str(); } else { - log(LogLevel::ERROR, error_message); + log(LogLevel::ERROR, "[Countly] fillEventsIntoJson, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } sqlite3_free_table(table); } else { - log(LogLevel::ERROR, "[Countly]fillEventsIntoJson, Could not open database."); + log(LogLevel::ERROR, "[Countly] fillEventsIntoJson, Could not open database."); } sqlite3_close(database); mutex->unlock(); @@ -1208,7 +1208,7 @@ int Countly::checkPersistentEQSize() { mutex->lock(); if (database_path.empty()) { mutex->unlock(); - log(LogLevel::FATAL, "[Countly]checkPersistentEQSize, SQLite database path is not set"); + log(LogLevel::FATAL, "[Countly] checkPersistentEQSize, SQLite database path is not set"); return result; } @@ -1223,24 +1223,24 @@ int Countly::checkPersistentEQSize() { return_value = sqlite3_get_table(database, "SELECT COUNT(*) FROM events;", &table, &row_count, &column_count, &error_message); if (return_value == SQLITE_OK) { result = atoi(table[1]); - log(LogLevel::DEBUG, "[Countly]checkPersistentEQSize, Fetched event count from database: [" + std::to_string(result) + "]"); + log(LogLevel::DEBUG, "[Countly] checkPersistentEQSize, Fetched event count from database: [" + std::to_string(result) + "]"); } else { - log(LogLevel::ERROR, error_message); + log(LogLevel::ERROR, "[Countly] checkPersistentEQSize, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } sqlite3_free_table(table); } else { - log(LogLevel::WARNING, "[Countly]checkPersistentEQSize, Could not open database"); + log(LogLevel::WARNING, "[Countly] checkPersistentEQSize, Could not open database"); } sqlite3_close(database); return result; } void Countly::addEventToSqlite(const cly::Event &event) { - log(LogLevel::DEBUG, "[Countly]addEventToSqlite, Start"); + log(LogLevel::DEBUG, "[Countly] addEventToSqlite, Start"); try { if (database_path.empty()) { - log(LogLevel::FATAL, "[Countly]addEventToSqlite, Cannot add event, SQLite database path is not set"); + log(LogLevel::FATAL, "[Countly] addEventToSqlite, Cannot add event, SQLite database path is not set"); return; } @@ -1264,13 +1264,13 @@ void Countly::addEventToSqlite(const cly::Event &event) { sqlite3_close(database); } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "[Countly]addEventToSqlite, error: " << e.what(); + log_message << "[Countly] addEventToSqlite, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } void Countly::clearPersistentEQ() { - log(LogLevel::DEBUG, "[Countly]clearPersistentEQ,"); + log(LogLevel::DEBUG, "[Countly] clearPersistentEQ, Start"); sqlite3 *database; int return_value; char *error_message; @@ -1279,10 +1279,10 @@ void Countly::clearPersistentEQ() { if (return_value == SQLITE_OK) { return_value = sqlite3_exec(database, "DELETE FROM events;", nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { - log(LogLevel::FATAL, error_message); + log(LogLevel::FATAL, "[Countly] clearPersistentEQ, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } else { - log(LogLevel::DEBUG, "[Countly]clearPersistentEQ, Cleared event queue"); + log(LogLevel::DEBUG, "[Countly] clearPersistentEQ, Cleared event queue"); } } sqlite3_close(database); @@ -1290,17 +1290,17 @@ void Countly::clearPersistentEQ() { void Countly::setDatabasePath(const std::string &path) { if (is_sdk_initialized) { - log(LogLevel::ERROR, "[Countly]setDatabasePath, This method can't be called after SDK initialization. Returning."); + log(LogLevel::ERROR, "[Countly] setDatabasePath, This method can't be called after SDK initialization. Returning."); return; } if (path == "" || path == " ") { - log(LogLevel::ERROR, "[Countly]setDatabasePath, Database path can not be empty or blank. Returning"); + log(LogLevel::ERROR, "[Countly] setDatabasePath, Database path can not be empty or blank. Returning."); return; } configuration->databasePath = path; - log(LogLevel::INFO, "[Countly]setDatabasePath, Setting database path = [" + path + "]"); + log(LogLevel::INFO, "[Countly] setDatabasePath, Setting database path = [" + path + "]"); } bool Countly::createEventTableSchema() { @@ -1317,21 +1317,21 @@ bool Countly::createEventTableSchema() { if (return_value == SQLITE_OK) { return_value = sqlite3_exec(database, "CREATE TABLE IF NOT EXISTS events (evtid INTEGER PRIMARY KEY, event TEXT)", nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { - log(LogLevel::ERROR, error_message); + log(LogLevel::ERROR, "[Countly] createEventTableSchema, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } else { result = true; } } else { const char *error = sqlite3_errmsg(database); - log(LogLevel::ERROR, "[Countly][createEventTableSchema] " + std::string(error)); + log(LogLevel::ERROR, "[Countly] createEventTableSchema, Could not open database: " + std::string(error)); database_path.clear(); } sqlite3_close(database); return result; } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "createEventTableSchema, error: " << e.what(); + log_message << "[Countly] createEventTableSchema, error: " << e.what(); log(LogLevel::FATAL, log_message.str()); } } @@ -1348,7 +1348,7 @@ std::string Countly::calculateChecksum(const std::string &salt, const std::strin std::string salted_data = data + salt; #ifdef COUNTLY_USE_CUSTOM_SHA256 if (configuration->sha256_function == nullptr) { - log(LogLevel::FATAL, "[Countly]calculateChecksum, Missing SHA 256 function"); + log(LogLevel::FATAL, "[Countly] calculateChecksum, Missing SHA 256 function"); return {}; } @@ -1380,7 +1380,7 @@ std::chrono::system_clock::duration Countly::getSessionDuration(std::chrono::sys std::chrono::system_clock::duration Countly::getSessionDuration() { return Countly::getSessionDuration(Countly::getTimestamp()); } void Countly::updateLoop() { - log(LogLevel::DEBUG, "[Countly]updateLoop, Start"); + log(LogLevel::DEBUG, "[Countly] updateLoop, Start"); mutex->lock(); running = true; mutex->unlock(); @@ -1428,13 +1428,13 @@ void Countly::_fetchRemoteConfig(const std::map &data) void Countly::updateRemoteConfig() { if (!is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][updateRemoteConfig] SDK is not initialized."); + log(LogLevel::WARNING, "[Countly] updateRemoteConfig, SDK is not initialized."); return; } mutex->lock(); if (!session_params["app_key"].is_string() || !session_params["device_id"].is_string()) { - log(LogLevel::ERROR, "[Countly]updateLoop, Error updating remote config, app key or device id is missing"); + log(LogLevel::ERROR, "[Countly] updateRemoteConfig, Error updating remote config, app key or device id is missing"); mutex->unlock(); return; } @@ -1472,7 +1472,7 @@ void Countly::_updateRemoteConfigWithSpecificValues(const std::maplock(); @@ -1494,7 +1494,7 @@ void Countly::updateRemoteConfigFor(std::string *keys, size_t key_count) { void Countly::updateRemoteConfigExcept(std::string *keys, size_t key_count) { if (!is_sdk_initialized) { - log(LogLevel::WARNING, "[Countly][updateRemoteConfigExcept] SDK is not initialized."); + log(LogLevel::WARNING, "[Countly] updateRemoteConfigExcept, SDK is not initialized."); return; } mutex->lock(); diff --git a/src/crash_module.cpp b/src/crash_module.cpp index 285538c..649231e 100644 --- a/src/crash_module.cpp +++ b/src/crash_module.cpp @@ -29,12 +29,12 @@ CrashModule::~CrashModule() { impl.reset(); } CrashModule::CrashModule(std::shared_ptr config, std::shared_ptr logger, std::shared_ptr requestModule, std::shared_ptr mutex) { impl.reset(new CrashModuleImpl(config, logger, requestModule, mutex)); - impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[CrashModule] Initialized")); + impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[Countly] [CrashModule] Initialized")); } // function to add breadcrumb void CrashModule::addBreadcrumb(const std::string &value) { - impl->_logger->log(LogLevel::INFO, "[CrashModule] addBreadcrumb : " + value); + impl->_logger->log(LogLevel::INFO, "[Countly] [CrashModule] addBreadcrumb, value = [" + value + "]"); impl->_mutex->lock(); // if breadcrumb threshold is reached, remove oldest breadcrumb @@ -49,36 +49,36 @@ void CrashModule::addBreadcrumb(const std::string &value) { // function to record exception void CrashModule::recordException(const std::string &title, const std::string &stackTrace, const bool fatal, const std::map &crashMetrics, const std::map &segmentation) { - impl->_logger->log(LogLevel::INFO, cly::utils::format_string("[CrashModule] recordException: title = %s, stackTrace = %s", title.c_str(), stackTrace.c_str())); + impl->_logger->log(LogLevel::INFO, cly::utils::format_string("[Countly] [CrashModule] recordException, title = [%s], stackTrace = [%s]", title.c_str(), stackTrace.c_str())); if (std::shared_ptr config = impl->_configProvider.lock()) { if (config->isCrashReportingEnabled() == false) { - impl->_logger->log(LogLevel::DEBUG, "[CrashModule] recordException: Crash reporting is disabled. Not recording exception."); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [CrashModule] recordException, Crash reporting is disabled. Not recording exception."); return; } } else { - impl->_logger->log(LogLevel::WARNING, "[CrashModule] recordException: ConfigurationProvider unavailable."); + impl->_logger->log(LogLevel::WARNING, "[Countly] [CrashModule] recordException, ConfigurationProvider unavailable."); return; } if (title.empty()) { - impl->_logger->log(LogLevel::WARNING, "[CrashModule] recordException : The parameter 'title' can't be empty"); + impl->_logger->log(LogLevel::WARNING, "[Countly] [CrashModule] recordException, The parameter 'title' can't be empty"); } if (stackTrace.empty()) { - impl->_logger->log(LogLevel::ERROR, "[CrashModule] recordException : The parameter 'stackTrace' can't be empty"); + impl->_logger->log(LogLevel::ERROR, "[Countly] [CrashModule] recordException, The parameter 'stackTrace' can't be empty"); } // check if the crash metric '_os' exists and is not empty auto it = crashMetrics.find("_os"); if (it == crashMetrics.end() || it->second.empty()) { - impl->_logger->log(LogLevel::ERROR, "[CrashModule] recordException : The crash metric '_os' can't be empty"); + impl->_logger->log(LogLevel::ERROR, "[Countly] [CrashModule] recordException, The crash metric '_os' can't be empty"); } // check if the crash metric '_app_version' exists and is not empty it = crashMetrics.find("_app_version"); if (it == crashMetrics.end() || it->second.empty()) { - impl->_logger->log(LogLevel::ERROR, "[CrashModule] recordException : The crash metric '_app_version' can't be empty"); + impl->_logger->log(LogLevel::ERROR, "[Countly] [CrashModule] recordException, The crash metric '_app_version' can't be empty"); } // lock mutex to avoid concurrent access diff --git a/src/request_module.cpp b/src/request_module.cpp index 69d99d6..210c87d 100644 --- a/src/request_module.cpp +++ b/src/request_module.cpp @@ -52,7 +52,7 @@ class RequestModule::RequestModuleImpl { std::string salted_data = data + salt; #ifdef COUNTLY_USE_CUSTOM_SHA256 if (_configuration->sha256_function == nullptr) { - _logger->log(LogLevel::FATAL, "Missing SHA 256 function"); + _logger->log(LogLevel::FATAL, "[Countly] [RequestModule] calculateChecksum, Missing SHA 256 function"); return {}; } @@ -78,7 +78,7 @@ class RequestModule::RequestModuleImpl { RequestModule::RequestModule(std::shared_ptr config, std::shared_ptr logger, std::shared_ptr requestBuilder, std::shared_ptr storageModule) { impl.reset(new RequestModuleImpl(config, logger, requestBuilder, storageModule)); - impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[RequestModule] Initialized")); + impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[Countly] [RequestModule] Initialized")); #if !defined(_WIN32) && !defined(COUNTLY_USE_CUSTOM_HTTP) curl_global_init(CURL_GLOBAL_ALL); @@ -101,17 +101,17 @@ static size_t countly_curl_write_callback(void *data, size_t byte_size, size_t n void RequestModule::addRequestToQueue(const std::map &data) { std::shared_ptr config = _configProvider.lock(); if (!config) { - impl->_logger->log(LogLevel::WARNING, "[RequestModule] addRequestToQueue: ConfigurationProvider unavailable. Not adding request."); + impl->_logger->log(LogLevel::WARNING, "[Countly] [RequestModule] addRequestToQueue: ConfigurationProvider unavailable. Not adding request."); return; } if (config->isTrackingEnabled() == false) { - impl->_logger->log(LogLevel::DEBUG, "[RequestModule] addRequestToQueue: Tracking is disabled. Not adding request to queue."); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] addRequestToQueue: Tracking is disabled. Not adding request to queue."); return; } if (config->getRequestQueueSizeLimit() <= impl->_storageModule->RQCount()) { - impl->_logger->log(LogLevel::WARNING, cly::utils::format_string("[RequestModule] addRequestToQueue: Request Queue is full. Dropping the oldest request.")); + impl->_logger->log(LogLevel::WARNING, cly::utils::format_string("[Countly] [RequestModule] addRequestToQueue: Request Queue is full. Dropping the oldest request.")); impl->_storageModule->RQRemoveFront(); } @@ -126,17 +126,17 @@ void RequestModule::processQueue(std::shared_ptr mutex) { if (std::shared_ptr config = _configProvider.lock()) { if (config->isTrackingEnabled() == false) { - impl->_logger->log(LogLevel::DEBUG, "[RequestModule] processQueue: Tracking is disabled. Not processing request queue."); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] processQueue: Tracking is disabled. Not processing request queue."); mutex->unlock(); return; } if (config->isNetworkingEnabled() == false) { - impl->_logger->log(LogLevel::DEBUG, "[RequestModule] processQueue: Networking is disabled. Not processing request queue."); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] processQueue: Networking is disabled. Not processing request queue."); mutex->unlock(); return; } } else { - impl->_logger->log(LogLevel::WARNING, "[RequestModule] processQueue: ConfigurationProvider unavailable, skipping queue processing."); + impl->_logger->log(LogLevel::WARNING, "[Countly] [RequestModule] processQueue: ConfigurationProvider unavailable, skipping queue processing."); mutex->unlock(); return; } @@ -156,9 +156,9 @@ void RequestModule::processQueue(std::shared_ptr mutex) { while (true) { mutex->lock(); - impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[RequestModule] processQueue: Processing the request queue.")); + impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[Countly] [RequestModule] processQueue: Processing the request queue.")); if (impl->_storageModule->RQCount() == 0) { - impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[RequestModule] processQueue: Queue is empty.")); + impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[Countly] [RequestModule] processQueue: Queue is empty.")); // stop sending requests once the queue is empty mutex->unlock(); @@ -171,7 +171,7 @@ void RequestModule::processQueue(std::shared_ptr mutex) { mutex->lock(); if (!response.success) { - impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[RequestModule] processQueue: Failed to deliver to server, will try again later.")); + impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[Countly] [RequestModule] processQueue: Failed to deliver to server, will try again later.")); // if the request was not a success, abort sending and try again in the future mutex->unlock(); break; @@ -183,7 +183,7 @@ void RequestModule::processQueue(std::shared_ptr mutex) { processedRequestsCounter++; if (processedRequestsCounter > impl->_configuration->maxProcessingBatchSize) { - impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[RequestModule] processQueue: Batch limit has been reached, will do next batch later.")); + impl->_logger->log(LogLevel::DEBUG, cly::utils::format_string("[Countly] [RequestModule] processQueue: Batch limit has been reached, will do next batch later.")); mutex->unlock(); break; } @@ -199,7 +199,7 @@ void RequestModule::processQueue(std::shared_ptr mutex) { HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { bool use_post = impl->_configuration->forcePost || (data.size() > COUNTLY_POST_THRESHOLD); - impl->_logger->log(LogLevel::DEBUG, "[Countly][sendHTTP] data: " + data); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] sendHTTP, data: [" + data + "]"); if (!impl->_configuration->salt.empty()) { std::string checksum = impl->calculateChecksum(impl->_configuration->salt, data); if (!data.empty()) { @@ -207,7 +207,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { } data += "checksum256=" + checksum; - impl->_logger->log(LogLevel::DEBUG, "[Countly][sendHTTP] with checksum, data: " + data); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] sendHTTP, with checksum, data: [" + data + "]"); } HTTPResponse response; @@ -215,7 +215,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { #ifdef COUNTLY_USE_CUSTOM_HTTP if (!impl->_configuration->http_client_function) { - impl->_logger->log(LogLevel::FATAL, "Missing HTTP client function"); + impl->_logger->log(LogLevel::FATAL, "[Countly] [RequestModule] sendHTTP, Missing HTTP client function"); return response; } @@ -304,7 +304,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { if (!body.empty()) { const nlohmann::json &parseResult = nlohmann::json::parse(body, nullptr, false); if (parseResult.is_discarded()) { - impl->_logger->log(LogLevel::WARNING, "[Countly][sendHTTP] Returned response from the server was not a valid JSON."); + impl->_logger->log(LogLevel::WARNING, "[Countly] [RequestModule] sendHTTP, Returned response from the server was not a valid JSON."); } else { response.data = parseResult; } @@ -338,7 +338,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { curl_easy_setopt(curl, CURLOPT_POSTFIELDS, data.c_str()); } - impl->_logger->log(LogLevel::DEBUG, "[Countly][sendHTTP] request: " + full_url_stream.str()); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] sendHTTP, request: [" + full_url_stream.str() + "]"); std::string full_url = full_url_stream.str(); curl_easy_setopt(curl, CURLOPT_URL, full_url.c_str()); @@ -357,7 +357,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { if (!body.empty()) { const nlohmann::json &parseResult = nlohmann::json::parse(body, nullptr, false); if (parseResult.is_discarded()) { - impl->_logger->log(LogLevel::WARNING, "[Countly][sendHTTP] Returned response from the server was not a valid JSON."); + impl->_logger->log(LogLevel::WARNING, "[Countly] [RequestModule] sendHTTP, Returned response from the server was not a valid JSON."); } else { response.data = parseResult; } @@ -366,7 +366,7 @@ HTTPResponse RequestModule::sendHTTP(std::string path, std::string data) { curl_easy_cleanup(curl); } #endif - impl->_logger->log(LogLevel::DEBUG, "[Countly][sendHTTP] response: " + response.data.dump()); + impl->_logger->log(LogLevel::DEBUG, "[Countly] [RequestModule] sendHTTP, response: [" + response.data.dump() + "]"); return response; #endif } diff --git a/src/storage_module_db.cpp b/src/storage_module_db.cpp index 5693b9f..84d9ac8 100644 --- a/src/storage_module_db.cpp +++ b/src/storage_module_db.cpp @@ -22,12 +22,12 @@ StorageModuleDB::~StorageModuleDB() {} void StorageModuleDB::init() { try { - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] initialized."); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] init, Initialized."); #ifdef COUNTLY_USE_SQLITE // Check if the database path is empty or blank if (_configuration->databasePath == "" || _configuration->databasePath == " ") { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] init: Database path can not be empty or blank!"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] init, Database path can not be empty or blank!"); return; } #endif @@ -40,14 +40,14 @@ void StorageModuleDB::init() { } } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "init, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] init, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); } } void StorageModuleDB::vacuumDatabase() { try { - _logger->log(LogLevel::INFO, "[StorageModuleDB][Vacuum] Will try to vacuum the database"); + _logger->log(LogLevel::INFO, "[Countly] [StorageModuleDB] vacuumDatabase, Will try to vacuum the database"); #ifdef COUNTLY_USE_SQLITE sqlite3 *database; @@ -57,27 +57,27 @@ void StorageModuleDB::vacuumDatabase() { if (return_value == SQLITE_OK) { return_value = sqlite3_exec(database, "VACUUM", nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { - _logger->log(LogLevel::ERROR, error_message); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] vacuumDatabase, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } else { - _logger->log(LogLevel::INFO, "[StorageModuleDB][Vacuum] Database vacuumed successfully"); + _logger->log(LogLevel::INFO, "[Countly] [StorageModuleDB] vacuumDatabase, Database vacuumed successfully"); } } else { const char *error = sqlite3_errmsg(database); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB][Vacuum] " + std::string(error)); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] vacuumDatabase, Could not open database: " + std::string(error)); } sqlite3_close(database); #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "vacuumDatabase, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] vacuumDatabase, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); } } bool StorageModuleDB::createSchema(const char tableName[], const char keyColumnName[], const char dataColumnName[]) { try { - _logger->log(LogLevel::INFO, "[StorageModuleDB][createSchema]"); + _logger->log(LogLevel::INFO, "[Countly] [StorageModuleDB] createSchema, Start"); bool result = false; #ifdef COUNTLY_USE_SQLITE @@ -97,14 +97,14 @@ bool StorageModuleDB::createSchema(const char tableName[], const char keyColumnN // Execute the SQL statement return_value = sqlite3_exec(database, statement.c_str(), nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { - _logger->log(LogLevel::ERROR, error_message); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] createSchema, SQLite error: " + std::string(error_message)); sqlite3_free(error_message); } else { result = true; } } else { const char *error = sqlite3_errmsg(database); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB][createSchema] " + std::string(error)); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] createSchema, Could not open database: " + std::string(error)); } // Close the SQLite database @@ -114,7 +114,7 @@ bool StorageModuleDB::createSchema(const char tableName[], const char keyColumnN return result; } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "createSchema, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] createSchema, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); return false; } @@ -124,11 +124,11 @@ bool StorageModuleDB::createSchema(const char tableName[], const char keyColumnN void StorageModuleDB::RQRemoveFront() { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQRemoveFront: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQRemoveFront, Module is not initialized"); return; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQRemoveFront"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQRemoveFront, Start"); #ifdef COUNTLY_USE_SQLITE // Declare SQLite database, return value and error message variables @@ -141,7 +141,7 @@ void StorageModuleDB::RQRemoveFront() { // Remove the first entry in the requests table std::ostringstream sql_statement_stream; sql_statement_stream << "DELETE FROM " << REQUESTS_TABLE_NAME << " WHERE " << REQUESTS_TABLE_REQUEST_ID << " = ( SELECT MIN(" << REQUESTS_TABLE_REQUEST_ID << ") FROM " << REQUESTS_TABLE_NAME << " );"; - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQRemoveFront SQL = " + sql_statement_stream.str()); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQRemoveFront, SQL = " + sql_statement_stream.str()); std::string sql_statement = sql_statement_stream.str(); @@ -149,7 +149,7 @@ void StorageModuleDB::RQRemoveFront() { return_value = sqlite3_exec(database, sql_statement.c_str(), nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQRemoveFront error = " + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQRemoveFront, error = " + error); sqlite3_free(error_message); } } @@ -158,7 +158,7 @@ void StorageModuleDB::RQRemoveFront() { #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "RQRemoveFront, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] RQRemoveFront, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); } } @@ -166,18 +166,18 @@ void StorageModuleDB::RQRemoveFront() { void StorageModuleDB::RQRemoveFront(std::shared_ptr request) { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQRemoveFront(request): Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQRemoveFront, Module is not initialized"); return; } if (request == nullptr) { // Check if request is null - _logger->log(LogLevel::WARNING, "[Countly][StorageModuleDB] RQRemoveFront request = null"); + _logger->log(LogLevel::WARNING, "[Countly] [StorageModuleDB] RQRemoveFront, request is null"); return; } // Log the request ID being removed - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQRemoveFront RequestID = " + std::to_string(request->getId())); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQRemoveFront, Removing RequestID = " + std::to_string(request->getId())); #ifdef COUNTLY_USE_SQLITE sqlite3 *database; @@ -189,7 +189,7 @@ void StorageModuleDB::RQRemoveFront(std::shared_ptr request) { // Build SQL statement to remove request from database std::ostringstream sql_statement_stream; sql_statement_stream << "DELETE FROM " << REQUESTS_TABLE_NAME << " WHERE " << REQUESTS_TABLE_REQUEST_ID << " = " << request->getId() << ';'; - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQRemoveFront SQL = " + sql_statement_stream.str()); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQRemoveFront SQL = " + sql_statement_stream.str()); std::string sql_statement = sql_statement_stream.str(); @@ -197,7 +197,7 @@ void StorageModuleDB::RQRemoveFront(std::shared_ptr request) { return_value = sqlite3_exec(database, sql_statement.c_str(), nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQRemoveFront error = " + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQRemoveFront error = " + error); sqlite3_free(error_message); } } @@ -214,11 +214,11 @@ void StorageModuleDB::RQRemoveFront(std::shared_ptr request) { long long StorageModuleDB::RQCount() { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQCount: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQCount, Module is not initialized"); return -1; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQCount"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQCount, Start"); long long requestCount = 0; #ifdef COUNTLY_USE_SQLITE @@ -242,7 +242,7 @@ long long StorageModuleDB::RQCount() { } else { // Log any errors encountered during the execution of the SQL statement std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQCount error = " + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQCount, error = " + error); sqlite3_free(error_message); } // Free the memory allocated for the result table @@ -253,12 +253,12 @@ long long StorageModuleDB::RQCount() { #endif // Log the number of requests in the requests table - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQCount requests count = " + std::to_string(requestCount)); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQCount, requests count = " + std::to_string(requestCount)); // Return the number of requests return requestCount; } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "RQCount, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] RQCount, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); return -1; } @@ -267,11 +267,11 @@ long long StorageModuleDB::RQCount() { std::vector> StorageModuleDB::RQPeekAll() { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQPeekAll: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQPeekAll, Module is not initialized"); return {}; // Return an empty vector if the module is not initialized } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQPeekAll"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQPeekAll, Start"); std::vector> v; // Initialize a vector to store the data entries @@ -304,7 +304,7 @@ std::vector> StorageModuleDB::RQPeekAll() { } else if (return_value != SQLITE_OK) { // If there was an error executing the query std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQPeekAll error =" + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQPeekAll, error = " + error); sqlite3_free(error_message); } // Free the result table @@ -316,7 +316,7 @@ std::vector> StorageModuleDB::RQPeekAll() { return v; // Return the vector containing all the data entries } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "RQPeekAll, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] RQPeekAll, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); return {}; } @@ -325,15 +325,15 @@ std::vector> StorageModuleDB::RQPeekAll() { void StorageModuleDB::RQInsertAtEnd(const std::string &request) { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQInsertAtEnd: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQInsertAtEnd, Module is not initialized"); return; // Checks if the module is initialized, returns if not } // Logs the request being inserted - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQInsertAtEnd request = " + request); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQInsertAtEnd, request = [" + request + "]"); if (request == "") { - _logger->log(LogLevel::WARNING, "[Countly][StorageModuleMemory] RQInsertAtEnd request is empty"); + _logger->log(LogLevel::WARNING, "[Countly] [StorageModuleDB] RQInsertAtEnd, request is empty"); return; // Checks if the request is empty, logs a warning and returns if it is } @@ -354,7 +354,7 @@ void StorageModuleDB::RQInsertAtEnd(const std::string &request) { return_value = sqlite3_exec(database, sql_statement.c_str(), nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQInsertAtEnd error =" + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQInsertAtEnd, error = " + error); sqlite3_free(error_message); } } @@ -363,7 +363,7 @@ void StorageModuleDB::RQInsertAtEnd(const std::string &request) { #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "RQInsertAtEnd, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] RQInsertAtEnd, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); } } @@ -371,10 +371,10 @@ void StorageModuleDB::RQInsertAtEnd(const std::string &request) { void StorageModuleDB::RQClearAll() { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQClearAll: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQClearAll, Module is not initialized"); return; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQClearAll"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQClearAll, Start"); #ifdef COUNTLY_USE_SQLITE sqlite3 *database; @@ -391,7 +391,7 @@ void StorageModuleDB::RQClearAll() { return_value = sqlite3_exec(database, sql_statement.c_str(), nullptr, nullptr, &error_message); if (return_value != SQLITE_OK) { // Check if SQL statement executed successfully std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQRemoveFront error = " + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQClearAll, error = " + error); sqlite3_free(error_message); } } @@ -400,7 +400,7 @@ void StorageModuleDB::RQClearAll() { #endif } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "RQClearAll, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] RQClearAll, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); } } @@ -409,11 +409,11 @@ const std::shared_ptr StorageModuleDB::RQPeekFront() { try { std::shared_ptr front = std::make_shared(-1, ""); // Initialize a shared pointer to a default-constructed DataEntry object if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQPeekFront: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQPeekFront, Module is not initialized"); return front; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQPeekFronts"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQPeekFront, Start"); #ifdef COUNTLY_USE_SQLITE sqlite3 *database; @@ -440,12 +440,12 @@ const std::shared_ptr StorageModuleDB::RQPeekFront() { std::string request = table[(event_index * column_count) + 1]; // Create a new DataEntry object and reset the shared pointer to point to it DataEntry *frontEntry = new DataEntry(std::stoll(requestId), request); - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] RQPeekFronts id =" + requestId); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] RQPeekFront, id = " + requestId); front.reset(frontEntry); } } else if (return_value != SQLITE_OK) { std::string error(error_message); - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] RQPeekFronts error =" + error); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] RQPeekFront, error = " + error); sqlite3_free(error_message); // free the error message pointer } sqlite3_free_table(table); // Free the table pointer @@ -456,7 +456,7 @@ const std::shared_ptr StorageModuleDB::RQPeekFront() { return front; // Return the shared pointer to the DataEntry object } catch (const std::system_error &e) { std::ostringstream log_message; - log_message << "RQPeekFront, error: " << e.what(); + log_message << "[Countly] [StorageModuleDB] RQPeekFront, error: " << e.what(); _logger->log(LogLevel::FATAL, log_message.str()); return std::shared_ptr(new DataEntry(-1, "")); } @@ -465,23 +465,23 @@ const std::shared_ptr StorageModuleDB::RQPeekFront() { void StorageModuleDB::storeSDKBehaviorSettings(const std::string &sdk_behavior_settings) { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] storeSDKBehaviorSettings: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] storeSDKBehaviorSettings, Module is not initialized"); return; } if (sdk_behavior_settings.empty()) { - _logger->log(LogLevel::WARNING, "[Countly][StorageModuleDB] storeSDKBehaviorSettings: Empty data"); + _logger->log(LogLevel::WARNING, "[Countly] [StorageModuleDB] storeSDKBehaviorSettings, Empty data"); return; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleDB] storeSDKBehaviorSettings"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleDB] storeSDKBehaviorSettings, Start"); #ifdef COUNTLY_USE_SQLITE sqlite3 *db = nullptr; sqlite3_stmt *stmt = nullptr; if (sqlite3_open(_configuration->databasePath.c_str(), &db) != SQLITE_OK) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] Failed to open database"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] storeSDKBehaviorSettings, Failed to open database"); return; } @@ -489,7 +489,7 @@ void StorageModuleDB::storeSDKBehaviorSettings(const std::string &sdk_behavior_s "VALUES (?, ?);"; if (sqlite3_prepare_v2(db, sql, -1, &stmt, nullptr) != SQLITE_OK) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] Failed to prepare statement"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] storeSDKBehaviorSettings, Failed to prepare statement"); sqlite3_close(db); return; } @@ -499,21 +499,21 @@ void StorageModuleDB::storeSDKBehaviorSettings(const std::string &sdk_behavior_s if (sqlite3_step(stmt) != SQLITE_DONE) { const char *err = sqlite3_errmsg(db); - _logger->log(LogLevel::ERROR, std::string("[Countly][StorageModuleDB] storeSDKBehaviorSettings failed: ") + err); + _logger->log(LogLevel::ERROR, std::string("[Countly] [StorageModuleDB] storeSDKBehaviorSettings, failed: [") + err + "]"); } sqlite3_finalize(stmt); sqlite3_close(db); #endif } catch (const std::exception &e) { - _logger->log(LogLevel::ERROR, std::string("[Countly][StorageModuleDB] storeSDKBehaviorSettings, exception: ") + e.what()); + _logger->log(LogLevel::ERROR, std::string("[Countly] [StorageModuleDB] storeSDKBehaviorSettings, exception: [") + e.what() + "]"); } } std::string StorageModuleDB::getSDKBehaviorSettings() { try { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] getSDKBehaviorSettings: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] getSDKBehaviorSettings, Module is not initialized"); return ""; } @@ -523,7 +523,7 @@ std::string StorageModuleDB::getSDKBehaviorSettings() { std::string result; if (sqlite3_open(_configuration->databasePath.c_str(), &db) != SQLITE_OK) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] Failed to open database"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] getSDKBehaviorSettings, Failed to open database"); return ""; } @@ -537,7 +537,7 @@ std::string StorageModuleDB::getSDKBehaviorSettings() { } } } else { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleDB] Failed to prepare statement"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleDB] getSDKBehaviorSettings, Failed to prepare statement"); } if (stmt) { @@ -550,7 +550,7 @@ std::string StorageModuleDB::getSDKBehaviorSettings() { return ""; #endif } catch (const std::exception &e) { - _logger->log(LogLevel::ERROR, std::string("[Countly][StorageModuleDB] getSDKBehaviorSettings, exception: ") + e.what()); + _logger->log(LogLevel::ERROR, std::string("[Countly] [StorageModuleDB] getSDKBehaviorSettings, exception: [") + e.what() + "]"); return ""; } } diff --git a/src/storage_module_memory.cpp b/src/storage_module_memory.cpp index 1409653..74ef3f7 100644 --- a/src/storage_module_memory.cpp +++ b/src/storage_module_memory.cpp @@ -13,17 +13,17 @@ StorageModuleMemory::~StorageModuleMemory() { } void StorageModuleMemory::init() { - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] initialized."); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] init, Initialized."); _is_initialized = true; } void StorageModuleMemory::RQRemoveFront() { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQRemoveFront: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQRemoveFront, Module is not initialized"); return; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQRemoveFront"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQRemoveFront, Start"); if (request_queue.size() > 0) { request_queue.pop_front(); } @@ -31,39 +31,39 @@ void StorageModuleMemory::RQRemoveFront() { void StorageModuleMemory::RQRemoveFront(std::shared_ptr request) { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQRemoveFront(request): Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQRemoveFront, Module is not initialized"); return; } if (request == nullptr) { - _logger->log(LogLevel::WARNING, "[Countly][StorageModuleMemory] RQRemoveFront request = null"); + _logger->log(LogLevel::WARNING, "[Countly] [StorageModuleMemory] RQRemoveFront, request is null"); return; } if (request_queue.size() > 0 && request->getId() == request_queue.front()->getId()) { - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQRemoveFront request = " + request->getData()); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQRemoveFront, Removing request = [" + request->getData() + "]"); request_queue.pop_front(); } } long long StorageModuleMemory::RQCount() { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQRemoveFront(request): Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQCount, Module is not initialized"); return -1; } long long size = request_queue.size(); - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQCount size = [" + std::to_string(size) + "]"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQCount, size = [" + std::to_string(size) + "]"); return size; } void StorageModuleMemory::RQInsertAtEnd(const std::string &request) { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQInsertAtEnd: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQInsertAtEnd, Module is not initialized"); return; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQInsertAtEnd request = " + request); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQInsertAtEnd, request = [" + request + "]"); if (request != "") { if (request_queue.empty()) { // Since the DB (Sqlite) storage module reset the primary key when all rows get deleted. To sync with the DB storage module, the memory storage module also reset '_lastUsedId' when the request queue is empty. @@ -76,17 +76,17 @@ void StorageModuleMemory::RQInsertAtEnd(const std::string &request) { entry.reset(new DataEntry(_lastUsedId, request)); request_queue.push_back(entry); } else { - _logger->log(LogLevel::WARNING, "[Countly][StorageModuleMemory] RQInsertAtEnd request is empty"); + _logger->log(LogLevel::WARNING, "[Countly] [StorageModuleMemory] RQInsertAtEnd, request is empty"); } } std::vector> StorageModuleMemory::RQPeekAll() { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQPeekAll: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQPeekAll, Module is not initialized"); return {}; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQPeekAll"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQPeekAll, Start"); int qSize = request_queue.size(); std::vector> v(qSize); for (int i = 0; i < request_queue.size(); ++i) { @@ -98,11 +98,11 @@ std::vector> StorageModuleMemory::RQPeekAll() { void StorageModuleMemory::RQClearAll() { if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQClearAll: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQClearAll, Module is not initialized"); return; } - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQClearAll"); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQClearAll, Start"); request_queue.clear(); } @@ -118,17 +118,17 @@ std::string StorageModuleMemory::getSDKBehaviorSettings() { const std::shared_ptr StorageModuleMemory::RQPeekFront() { std::shared_ptr front = nullptr; if (!_is_initialized) { - _logger->log(LogLevel::ERROR, "[Countly][StorageModuleMemory] RQPeekFront: Module is not initialized"); + _logger->log(LogLevel::ERROR, "[Countly] [StorageModuleMemory] RQPeekFront, Module is not initialized"); front.reset(new DataEntry(-1, "")); return front; } if (request_queue.size() > 0) { front = request_queue.front(); - _logger->log(LogLevel::DEBUG, "[Countly][StorageModuleMemory] RQPeekFront: request = " + front->getData()); + _logger->log(LogLevel::DEBUG, "[Countly] [StorageModuleMemory] RQPeekFront, request = [" + front->getData() + "]"); } else { front.reset(new DataEntry(-1, "")); - _logger->log(LogLevel::WARNING, "[Countly][StorageModuleMemory] RQPeekFront: Request queue is empty."); + _logger->log(LogLevel::WARNING, "[Countly] [StorageModuleMemory] RQPeekFront, Request queue is empty."); } return front; diff --git a/src/views_module.cpp b/src/views_module.cpp index af8bb23..2b833c9 100644 --- a/src/views_module.cpp +++ b/src/views_module.cpp @@ -76,11 +76,11 @@ class ViewsModule::ViewModuleImpl { std::string _openView(const std::string &name, const std::map &segmentation) { if (std::shared_ptr config = _configProvider.lock()) { if (config->isViewTrackingEnabled() == false) { - _logger->log(LogLevel::DEBUG, "[ViewsModule] _openView: View tracking is disabled. Not opening view."); + _logger->log(LogLevel::DEBUG, "[Countly] [ViewsModule] _openView, View tracking is disabled. Not opening view."); return ""; } } else { - _logger->log(LogLevel::WARNING, "[ViewsModule] _openView: ConfigurationProvider unavailable."); + _logger->log(LogLevel::WARNING, "[Countly] [ViewsModule] _openView, ConfigurationProvider unavailable."); return ""; } ViewModuleImpl::ViewInfo *v = new ViewModuleImpl::ViewInfo(); @@ -99,17 +99,17 @@ class ViewsModule::ViewModuleImpl { void _closeViewWithName(const std::string &name) { if (std::shared_ptr config = _configProvider.lock()) { if (config->isViewTrackingEnabled() == false) { - _logger->log(LogLevel::DEBUG, "[ViewsModule] _closeViewWithName: View tracking is disabled. Not closing view."); + _logger->log(LogLevel::DEBUG, "[Countly] [ViewsModule] _closeViewWithName, View tracking is disabled. Not closing view."); return; } } else { - _logger->log(LogLevel::WARNING, "[ViewsModule] _closeViewWithName: ConfigurationProvider unavailable."); + _logger->log(LogLevel::WARNING, "[Countly] [ViewsModule] _closeViewWithName, ConfigurationProvider unavailable."); return; } std::shared_ptr v = findViewByName(name); if (v == nullptr) { - _logger->log(cly::LogLevel::WARNING, cly::utils::format_string("[ViewModuleImpl] _closeViewWithName: Couldn't found " - "view with name = %s", + _logger->log(cly::LogLevel::WARNING, cly::utils::format_string("[Countly] [ViewsModule] _closeViewWithName, Couldn't find " + "view with name = [%s]", name.c_str())); return; } @@ -119,17 +119,17 @@ class ViewsModule::ViewModuleImpl { void _closeViewWithID(const std::string &viewId) { if (std::shared_ptr config = _configProvider.lock()) { if (config->isViewTrackingEnabled() == false) { - _logger->log(LogLevel::DEBUG, "[ViewsModule] _closeViewWithID: View tracking is disabled. Not closing view."); + _logger->log(LogLevel::DEBUG, "[Countly] [ViewsModule] _closeViewWithID, View tracking is disabled. Not closing view."); return; } } else { - _logger->log(LogLevel::WARNING, "[ViewsModule] _closeViewWithID: ConfigurationProvider unavailable."); + _logger->log(LogLevel::WARNING, "[Countly] [ViewsModule] _closeViewWithID, ConfigurationProvider unavailable."); return; } if (_viewsStartTime.find(viewId) == _viewsStartTime.end()) { - _logger->log(cly::LogLevel::WARNING, cly::utils::format_string("[ViewModuleImpl] _closeViewWithID: Couldn't found " - "view with viewId = %s", + _logger->log(cly::LogLevel::WARNING, cly::utils::format_string("[Countly] [ViewsModule] _closeViewWithID, Couldn't find " + "view with viewId = [%s]", viewId.c_str())); return; } @@ -141,17 +141,17 @@ class ViewsModule::ViewModuleImpl { ViewsModule::ViewsModule(cly::CountlyDelegates *cly, std::shared_ptr logger) { impl.reset(new ViewModuleImpl(cly, logger)); - impl->_logger->log(cly::LogLevel::DEBUG, cly::utils::format_string("[ViewsModule] Initialized")); + impl->_logger->log(cly::LogLevel::DEBUG, cly::utils::format_string("[Countly] [ViewsModule] Initialized")); } ViewsModule::~ViewsModule() { impl.reset(); } std::string ViewsModule::openView(const std::string &name, const std::map &segmentation) { - impl->_logger->log(cly::LogLevel::INFO, cly::utils::format_string("[ViewsModule] openView: name = %s, segmentation = %s", name.c_str(), utils::mapToString(segmentation).c_str())); + impl->_logger->log(cly::LogLevel::INFO, cly::utils::format_string("[Countly] [ViewsModule] openView, name = [%s], segmentation = [%s]", name.c_str(), utils::mapToString(segmentation).c_str())); if (name.empty()) { - impl->_logger->log(cly::LogLevel::WARNING, "[ViewsModule] openView: view name can not be null or empty!"); + impl->_logger->log(cly::LogLevel::WARNING, "[Countly] [ViewsModule] openView, view name can not be null or empty!"); return {}; } @@ -159,20 +159,20 @@ std::string ViewsModule::openView(const std::string &name, const std::map_logger->log(cly::LogLevel::INFO, cly::utils::format_string("[ViewsModule] closeViewWithName: name = %s", name.c_str())); + impl->_logger->log(cly::LogLevel::INFO, cly::utils::format_string("[Countly] [ViewsModule] closeViewWithName, name = [%s]", name.c_str())); if (name.empty()) { - impl->_logger->log(cly::LogLevel::WARNING, "[ViewsModule] closeViewWithName: view name can not be null or empty!"); + impl->_logger->log(cly::LogLevel::WARNING, "[Countly] [ViewsModule] closeViewWithName, view name can not be null or empty!"); return; } impl->_closeViewWithName(name); } void ViewsModule::closeViewWithID(const std::string &viewId) { - impl->_logger->log(cly::LogLevel::INFO, cly::utils::format_string("[ViewsModule] closeViewWithID: viewId = %s", viewId.c_str())); + impl->_logger->log(cly::LogLevel::INFO, cly::utils::format_string("[Countly] [ViewsModule] closeViewWithID, viewId = [%s]", viewId.c_str())); if (viewId.empty()) { - impl->_logger->log(cly::LogLevel::WARNING, "[ViewsModule] closeViewWithID: viewId can not be null or empty!"); + impl->_logger->log(cly::LogLevel::WARNING, "[Countly] [ViewsModule] closeViewWithID, viewId can not be null or empty!"); return; }