/* 2014, Copyright © Intel Coporation, license APACHE-2.0, see LICENSE file */
-#include <iostream>
#include <cstdio>
#include "common/app_installer.h"
#include "common/context_installer.h"
#include "common/pkgmgr_signal.h"
+#include "utils/logging.h"
namespace common_installer {
int ret = 0;
for (; it != itEnd; ++it) {
if ((*it)->process() != Step::Status::OK) {
- std::cout << "Error during processing" << std::endl;
+ LOG(ERROR) << "Error during processing";
ret = -1;
break;
}
}
if (it != itEnd) {
- std::cout << "Failure occurs" << std::endl;
+ LOG(ERROR) << "Failure occurs";
do {
if ((*it)->undo() != Step::Status::OK) {
- std::cout << "Error during undo operation" << std::endl;
+ LOG(ERROR) << "Error during undo operation";
ret = -2;
}
} while (it-- != itStart);
} else {
while (it-- != itStart) {
if ((*it)->clean() != Step::Status::OK) {
- std::cout << "Error during clean operation" << std::endl;
+ LOG(ERROR) << "Error during clean operation";
ret = -3;
break;
}
#include <memory>
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
std::list<std::unique_ptr<Step>> steps_;
std::unique_ptr<ContextInstaller> context_;
+
+ SCOPE_LOG_TAG(AppInstaller)
};
} // namespace common_installer
#include "common/pkgmgr_signal.h"
#include <cassert>
-#include <iostream>
-#define DBG(msg) std::cout << "[PkgmgrSignal] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: PkgmgrSignal] " << msg << std::endl;
+#include "utils/logging.h"
namespace common_installer {
!pkgid.empty() ? pkgid.c_str() : "",
key,
value)) {
- ERR("Fail to send pkgmgr signal");
+ LOG(ERROR) << "Fail to send pkgmgr signal";
return false;
}
- DBG("Success to send pkgmgr signal PKGID=" << pkgid
- << " KEY=" << key
- << " VALUE=" << value);
+ LOG(DEBUG) << "Success to send pkgmgr signal"
+ << " PKGID=" << pkgid
+ << " KEY=" << key
+ << " VALUE=" << value;
return true;
}
#include <security-manager.h>
-#include <iostream>
-
-// TODO(t.iwanek): logging mechanism...
-#define DBG(msg) std::cout << "[DEBUG:SecurityContext] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR:SecurityContext] " << msg << std::endl;
+#include "utils/logging.h"
namespace bf = boost::filesystem;
const boost::filesystem::path& path, manifest_x* manifest,
app_inst_req* req) {
if (app_id.empty() || pkg_id.empty()) {
- ERR("Appid or pkgid is empty. Both values must be set");
+ LOG(ERROR) << "Appid or pkgid is empty. Both values must be set";
return false;
}
int error = security_manager_app_inst_req_new(&req);
if (error != SECURITY_MANAGER_SUCCESS) {
- ERR("Failed while calling security_manager_app_inst_req_new failed "
- << "(error code: " << error << ")");
+ LOG(ERROR)
+ << "Failed while calling security_manager_app_inst_req_new failed "
+ << "(error code: " << error << ")";
return false;
}
if (!PrepareRequest(app_id, pkg_id, path, manifest, req)) {
- ERR("Failed while preparing security_manager_app_inst_req");
+ LOG(ERROR) << "Failed while preparing security_manager_app_inst_req";
security_manager_app_inst_req_free(req);
return false;
}
error = security_manager_app_install(req);
if (error != SECURITY_MANAGER_SUCCESS) {
- ERR("Failed while calling security_manager_app_install failed "
- << "(error code: " << error << ")");
+ LOG(ERROR) << "Failed while calling security_manager_app_install failed "
+ << "(error code: " << error << ")";
security_manager_app_inst_req_free(req);
return false;
}
int error = security_manager_app_inst_req_new(&req);
if (error != SECURITY_MANAGER_SUCCESS) {
- ERR("Failed while calling security_manager_app_inst_req_new "
- << "(error code: " << error << ")");
+ LOG(ERROR) << "Failed while calling security_manager_app_inst_req_new "
+ << "(error code: " << error << ")";
return false;
}
if (!PrepareRequest(app_id, pkg_id, bf::path(), nullptr, req)) {
- ERR("Failed while preparing security_manager_app_inst_req");
+ LOG(ERROR) << "Failed while preparing security_manager_app_inst_req";
security_manager_app_inst_req_free(req);
return false;
}
error = security_manager_app_uninstall(req);
if (error != SECURITY_MANAGER_SUCCESS) {
- ERR("Failed while calling security_manager_app_uninstall failed "
- << "(error code: " << error << ")");
+ LOG(ERROR) << "Failed while calling security_manager_app_uninstall failed "
+ << "(error code: " << error << ")";
security_manager_app_inst_req_free(req);
return false;
}
#include <cassert>
#include <cstring>
-#include <iostream>
#include <string>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Copy] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Copy] " << msg << std::endl;
-
namespace common_installer {
namespace copy {
install_path /= fs::path(context_->manifest_data()->mainapp_id);
if (!utils::CopyDir(fs::path(context_->unpack_directory()), install_path)) {
- ERR("Fail to copy tmp dir: " << context_->unpack_directory()
- << " to dst dir: " << install_path.string());
+ LOG(ERROR) << "Fail to copy tmp dir: " << context_->unpack_directory()
+ << " to dst dir: " << install_path.string();
return Step::Status::ERROR;
}
- DBG("Successfully copy: " << context_->unpack_directory()
- << " to: " << install_path.string() << " directory");
+ LOG(INFO) << "Successfully copy: " << context_->unpack_directory()
+ << " to: " << install_path.string() << " directory";
return Status::OK;
}
Step::Status StepCopy::clean() {
- DBG("Remove tmp dir: " << context_->unpack_directory());
+ LOG(DEBUG) << "Remove tmp dir: " << context_->unpack_directory();
fs::remove_all(context_->unpack_directory());
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace copy {
Status process() override;
Status clean() override;
Status undo() override;
+
+ SCOPE_LOG_TAG(Copy)
};
} // namespace copy
#include <cassert>
#include <cstring>
-#include <iostream>
#include <string>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[GenerateXML] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: GenerateXML] " << msg << std::endl;
-
namespace fs = boost::filesystem;
namespace common_installer {
boost::system::error_code error;
if ((!context_->manifest_data()->uiapplication) &&
(!context_->manifest_data()->serviceapplication)) {
- ERR("There is neither UI applications nor"
- << "Services applications described!\n");
+ LOG(ERROR) << "There is neither UI applications nor"
+ << "Services applications described!";
return Step::Status::ERROR;
}
writer = xmlNewTextWriterFilename(context_->xml_path().c_str(), 0);
if (!writer) {
- ERR("Failed to create new file\n");
+ LOG(ERROR) << "Failed to create new file";
return Step::Status::ERROR;
}
fs::rename(app_icon, icon_path_ /= icon);
} else {
fs::create_symlink(default_icon, icon_path_ /= icon, error);
- DBG("Icon is not found in package, the default icon is setting");
+ LOG(DEBUG) << "Icon is not found in package, the default icon is setting";
}
xmlTextWriterWriteFormatElement(writer, BAD_CAST "icon",
fs::rename(app_icon, icon_path_ /= icon);
} else {
fs::rename(default_icon, icon_path_ /= icon);
- DBG("Icon is not found in package, the default icon is setting");
+ LOG(DEBUG) << "Icon is not found in package, the default icon is setting";
}
for (appcontrol_x* appc_svc = svc->appcontrol; appc_svc != nullptr;
if (pkgmgr_parser_check_manifest_validation(
context_->xml_path().c_str()) != 0) {
- DBG("Manifest is not valid");
+ LOG(ERROR) << "Manifest is not valid";
return Step::Status::ERROR;
}
- DBG("Successfully create manifest xml " << context_->xml_path());
+ LOG(DEBUG) << "Successfully create manifest xml " << context_->xml_path();
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace generate_xml {
private:
boost::filesystem::path icon_path_;
+
+ SCOPE_LOG_TAG(GenerateXML)
};
} // namespace generate_xml
#include <boost/filesystem.hpp>
#include <cassert>
#include <cstring>
-#include <iostream>
#include <cstdio>
#include <string>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Parse] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Parse] " << msg << std::endl;
-
namespace common_installer {
namespace parse {
manifest_x* mfx = pkgmgr_parser_usr_process_manifest_xml(
context_->xml_path().c_str(), context_->uid());
if (!mfx) {
- DBG("Failed to parse tizen manifest xml " << context_->xml_path().c_str());
+ LOG(ERROR) << "Failed to parse tizen manifest xml " << context_->xml_path();
return Step::Status::ERROR;
}
context_->set_manifest(mfx);
context_->set_pkg_path(context_->GetApplicationPath());
- DBG("Successfully parse tizen manifest xml");
+ LOG(DEBUG) << "Successfully parse tizen manifest xml";
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace parse {
Status process() override;
Status clean() override;
Status undo() override;
+
+ SCOPE_LOG_TAG(Parse)
};
} // namespace parse
#include <boost/filesystem.hpp>
#include <cassert>
#include <cstring>
-#include <iostream>
#include <cstdio>
#include <string>
-#include "common/utils.h"
-#define DBG(msg) std::cout << "[Record] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Record] " << msg << std::endl;
+#include "common/utils.h"
namespace {
context_->xml_path().c_str(), appinst_tags);
if (ret != 0) {
- ERR("Failed to record package into database");
+ LOG(ERROR) << "Failed to record package into database";
return Step::Status::ERROR;
}
- DBG("Successfully install the application");
+ LOG(INFO) << "Successfully install the application";
return Status::OK;
}
cmd = std::string(kAilInit) + ";" + kPkgInit;
if (execv(cmd.c_str(), nullptr) == -1) {
- ERR("Error during execvp %s");
+ LOG(ERROR) << "Error during execvp %s";
return Step::Status::ERROR;
}
- DBG("Successfuly clean database");
+ LOG(INFO) << "Successfuly clean database";
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace record {
Status process() override;
Status clean() override;
Status undo() override;
+
+ SCOPE_LOG_TAG(Record)
};
} // namespace record
#include <pkgmgr-info.h>
#include <cstring>
-#include <iostream>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Remove] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Remove] " << msg << std::endl;
-
namespace common_installer {
namespace remove {
uiapplication_x* ui = context_->manifest_data()->uiapplication;
if (!fs::exists(context_->pkg_path()))
- DBG("dir: " << context_->pkg_path() << "not exist");
+ LOG(DEBUG) << "dir: " << context_->pkg_path() << "not exist";
fs::remove_all(context_->pkg_path());
for (; ui != nullptr; ui = ui->next) {
}
fs::remove_all(context_->xml_path());
- DBG("Removing dir: " << context_->pkg_path());
+ LOG(DEBUG) << "Removing dir: " << context_->pkg_path();
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace remove {
Status process() override;
Status clean() override;
Status undo() override;
+
+ SCOPE_LOG_TAG(Remove)
};
} // namespace remove
#include "common/step/step_revoke_security.h"
-#include <iostream>
-
#include "common/security_registration.h"
-// TODO(t.iwanek): logging mechanism...
-#define DBG(msg) std::cout << "[RevokeSecurity] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR:RevokeSecurity] " << msg << std::endl;
-
namespace common_installer {
namespace revoke_security {
context_->pkgid(), context_->manifest_data())) {
return Status::ERROR;
}
- DBG("Security context uninstalled");
+ LOG(DEBUG) << "Security context uninstalled";
return Status::OK;
}
context_->manifest_data())) {
return Status::ERROR;
}
- DBG("Security context installed");
+ LOG(DEBUG) << "Security context installed";
return Status::OK;
}
#define COMMON_STEP_STEP_REVOKE_SECURITY_H_
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace revoke_security {
Status process() override;
Status undo() override;
Status clean() override { return Status::OK; }
+
+ SCOPE_LOG_TAG(RevokeSecurity)
};
} // namespace revoke_security
#include "common/step/step_security.h"
-#include <iostream>
-
#include "common/security_registration.h"
-// TODO(t.iwanek): logging mechanism...
-#define DBG(msg) std::cout << "[Security] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR:Security] " << msg << std::endl;
-
namespace common_installer {
namespace security {
context_->manifest_data())) {
return Status::ERROR;
}
- DBG("Security context installed");
+ LOG(DEBUG) << "Security context installed";
return Status::OK;
}
context_->pkgid(), context_->manifest_data())) {
return Status::ERROR;
}
- DBG("Security context uninstalled");
+ LOG(DEBUG) << "Security context uninstalled";
return Status::OK;
}
#define COMMON_STEP_STEP_SECURITY_H_
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace security {
Status process() override;
Status undo() override;
Status clean() override { return Status::OK; }
+
+ SCOPE_LOG_TAG(Security)
};
} // namespace security
#include "common/step/step_signal.h"
-#include <iostream>
+#include <pkgmgr-info.h>
+#include <unistd.h>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Signal] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Signal] " << msg << std::endl;
-
namespace common_installer {
namespace signal {
context_->manifest_data()->type, context_->pkgid())) {
return Status::ERROR;
}
- DBG("Send Start");
+ LOG(DEBUG) << "Send Start";
return Status::OK;
}
context_->manifest_data()->type, context_->pkgid())) {
return Status::ERROR;
}
- DBG("Send Success");
+ LOG(DEBUG) << "Send Success";
return Status::OK;
}
context_->manifest_data()->type, context_->pkgid())) {
return Status::ERROR;
}
- DBG("Send Error");
+ LOG(ERROR) << "Send Error";
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace signal {
Status process() override;
Status clean() override;
Status undo() override;
+
+ private:
+ bool sendSignal(ContextInstaller* data, const std::string& key,
+ const std::string& value);
+
+ SCOPE_LOG_TAG(Signal)
};
} // namespace signal
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace signature {
Status process() override;
Status undo() override { return Status::OK; }
Status clean() override { return Status::OK; }
+
+ SCOPE_LOG_TAG(Signature)
};
} // namespace signature
#include <boost/filesystem.hpp>
#include <cassert>
#include <cstring>
-#include <iostream>
#include "common/step/step_unregister.h"
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Unregister] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Unregister] " << msg << std::endl;
namespace common_installer {
namespace unregister {
context_->xml_path().c_str(), appinst_tags);
if (ret != 0) {
- DBG("Failed to unregister package into database");
+ LOG(ERROR) << "Failed to unregister package into database";
return Status::ERROR;
}
- DBG("Successfully unregister the application");
+ LOG(DEBUG) << "Successfully unregister the application";
return Status::OK;
}
Step::Status StepUnregister::clean() {
- DBG("Empty 'clean' method");
+ LOG(DEBUG) << "Empty 'clean' method";
return Status::OK;
}
Step::Status StepUnregister::undo() {
- DBG("Empty 'undo' method");
+ LOG(DEBUG) << "Empty 'undo' method";
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace unregister {
Step::Status process() override;
Step::Status clean() override;
Step::Status undo() override;
+
+ SCOPE_LOG_TAG(Unregister)
};
} // namespace unregister
#include <cstdlib>
#include <climits>
#include <cstring>
-#include <iostream>
#include <string>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Unzip] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Unzip] " << msg << std::endl;
-
#define ZIPBUFSIZE 8192
#define ZIPMAXPATH 256
Step::Status StepUnzip::ExtractToTmpDir(const char* src,
const boost::filesystem::path& tmp_dir) {
if (is_extracted_) {
- ERR(src << " is already extracted");
+ LOG(ERROR) << src << " is already extracted";
return Status::OK;
}
unzFile* zip_file = static_cast<unzFile*>(unzOpen(src));
if (zip_file == NULL) {
- ERR("Failed to open the source dir: " << src);
+ LOG(ERROR) << "Failed to open the source dir: " << src;
return Step::Status::ERROR;
}
if (unzGetGlobalInfo(zip_file, &info) != UNZ_OK) {
- ERR("Failed to read global info");
+ LOG(ERROR) << "Failed to read global info";
unzClose(zip_file);
return Step::Status::ERROR;
}
for (uLong i = 0; i < info.number_entry; i++) {
if (unzGetCurrentFileInfo(zip_file, &raw_file_info, raw_file_name_in_zip,
sizeof(raw_file_name_in_zip), NULL, 0, NULL, 0) != UNZ_OK) {
- ERR("Failed to read file info");
+ LOG(ERROR) << "Failed to read file info";
unzClose(zip_file);
return Step::Status::ERROR;
}
boost::filesystem::path filename_in_zip_path(raw_file_name_in_zip);
if (!filename_in_zip_path.parent_path().empty()) {
if (!utils::CreateDir(filename_in_zip_path.parent_path())) {
- ERR("Failed to create directory: "
- << filename_in_zip_path.parent_path());
+ LOG(ERROR) << "Failed to create directory: "
+ << filename_in_zip_path.parent_path();
return Step::Status::ERROR;
}
}
if (unzOpenCurrentFile(zip_file) != UNZ_OK) {
- ERR("Failed to open file");
+ LOG(ERROR) << "Failed to open file";
unzClose(zip_file);
return Step::Status::ERROR;
}
if (!is_directory(filename_in_zip_path)) {
FILE *out = fopen(raw_file_name_in_zip, "wb");
if (!out) {
- ERR("Failed to open destination ");
+ LOG(ERROR) << "Failed to open destination ";
unzCloseCurrentFile(zip_file);
return Step::Status::ERROR;
}
do {
ret = unzReadCurrentFile(zip_file, read_buffer, ZIPBUFSIZE);
if (ret < 0) {
- ERR("Failed to read data: " << ret);
+ LOG(ERROR) << "Failed to read data: " << ret;
unzCloseCurrentFile(zip_file);
return Step::Status::ERROR;
} else {
if ((i+1) < info.number_entry) {
if (unzGoToNextFile(zip_file) != UNZ_OK) {
- ERR("Failed to read next file");
+ LOG(ERROR) << "Failed to read next file";
unzCloseCurrentFile(zip_file);
return Step::Status::ERROR;
}
GenerateTmpDir(context_->GetRootApplicationPath());
if (!utils::CreateDir(tmp_dir)) {
- ERR("Failed to create temp directory: " << tmp_dir);
+ LOG(ERROR) << "Failed to create temp directory: " << tmp_dir;
return Step::Status::ERROR;
}
if (ExtractToTmpDir(context_->file_path().c_str(), tmp_dir)
!= Step::Status::OK) {
- ERR("Failed to process unpack step");
+ LOG(ERROR) << "Failed to process unpack step";
return Step::Status::ERROR;
}
context_->set_unpack_directory(tmp_dir.string());
- DBG(context_->file_path() << " was successfully unzipped into "
- << context_->unpack_directory());
+ LOG(INFO) << context_->file_path() << " was successfully unzipped into "
+ << context_->unpack_directory();
return Status::OK;
}
Step::Status StepUnzip::undo() {
if (access(context_->unpack_directory().c_str(), F_OK) == 0) {
boost::filesystem::remove_all(context_->unpack_directory());
- DBG("remove temp dir: " << context_->unpack_directory());
+ LOG(DEBUG) << "remove temp dir: " << context_->unpack_directory();
}
return Status::OK;
}
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace common_installer {
namespace unzip {
const boost::filesystem::path& tmp_dir);
bool is_extracted_;
+
+ SCOPE_LOG_TAG(Unzip)
};
} // namespace unzip
#include "common/utils.h"
#include <boost/filesystem/path.hpp>
-#include <iostream>
#include <string>
-#define ERR(msg) std::cout << "[ERROR] " << msg << std::endl;
+#include "utils/logging.h"
namespace utils {
boost::system::error_code error;
fs::create_directories(path, error);
if (error) {
- ERR("Failed to create directory: "
- << boost::system::system_error(error).what());
+ LOG(ERROR) << "Failed to create directory: "
+ << boost::system::system_error(error).what();
return false;
}
| fs::group_read | fs::others_read,
error);
if (error) {
- ERR("Failed to set permission: "
- << boost::system::system_error(error).what());
+ LOG(ERROR) << "Failed to set permission: "
+ << boost::system::system_error(error).what();
return false;
}
return true;
try {
// Check whether the function call is valid
if (!fs::exists(src) || !fs::is_directory(src)) {
- ERR("Source directory " << src.string()
- << " does not exist or is not a directory.");
+ LOG(ERROR) << "Source directory " << src.string()
+ << " does not exist or is not a directory.";
return false;
}
if (fs::exists(dst)) {
- ERR("Destination directory " << dst.string() << " already exists.");
+ LOG(ERROR) << "Destination directory " << dst.string()
+ << " already exists.";
return false;
}
// Create the destination directory
if (!CreateDir(dst)) {
- ERR("Unable to create destination directory" << dst.string());
+ LOG(ERROR) << "Unable to create destination directory" << dst.string();
return false;
}
} catch (const fs::filesystem_error& error) {
- ERR(error.what());
+ LOG(ERROR) << error.what();
}
// Iterate through the source directory
fs::copy_file(current, dst / current.filename());
}
} catch (const fs::filesystem_error& error) {
- ERR(error.what());
+ LOG(ERROR) << error.what();
}
}
return true;
#include <set>
#include <string>
-#include "utils/logging.h"
#include "signature/signature_data.h"
#include "signature/signature_parser.h"
#include "signature/signature_xmlsec_adaptor.h"
#include <string>
+#include "utils/logging.h"
#include "utils/macros.h"
namespace common_installer {
static Status Check(const boost::filesystem::path& widget_path);
private:
+ SCOPE_LOG_TAG(SignatureValidator)
+
DISALLOW_COPY_AND_ASSIGN(SignatureValidator);
};
#define UTILS_LOGGING_H_
#include <cassert>
+#include <iomanip>
#include <iostream>
#include <sstream>
template<LogLevel> struct LogTag;
template<> struct LogTag<LogLevel::LOG_ERROR> {
- static constexpr const char* value = "\033[0;31m[ERROR] \033[0m";
+ static constexpr const char* value = "\033[1;31m| ERROR |\033[0m";
};
template<> struct LogTag<LogLevel::LOG_WARNING> {
- static constexpr const char* value = "\033[0;33m[WARNING]\033[0m";
+ static constexpr const char* value = "\033[1;33m| WARNING |\033[0m";
};
template<> struct LogTag<LogLevel::LOG_INFO> {
- static constexpr const char* value = "\033[0;32m[INFO] \033[0m";
+ static constexpr const char* value = "\033[1;32m| INFO |\033[0m";
};
template<> struct LogTag<LogLevel::LOG_DEBUG> {
- static constexpr const char* value = "\033[0m[DEBUG] \033[0m";
+ static constexpr const char* value = "\033[0m| DEBUG |\033[0m";
};
class LogCatcher {
} // namespace utils
+inline static const constexpr char* __tag_for_logging() {
+ return "";
+}
+
+// To be defined in class namespace if user want different log tag for given
+// scope
+#define SCOPE_LOG_TAG(TAG) \
+ inline static const constexpr char* __tag_for_logging() { \
+ return #TAG; \
+ } \
+
// Simple logging macro of following usage:
// LOG(LEVEL) << object_1 << object_2 << object_n;
// where:
// LEVEL = ERROR | WARNING | INFO | DEBUG
#define LOG(LEVEL) \
::utils::LogCatcher() & std::ostringstream() \
- << ::utils::LogTag<::utils::LogLevel::LOG_##LEVEL>::value \
+ << ::utils::LogTag<::utils::LogLevel::LOG_ ## LEVEL>::value \
+ << " " << std::setw(20) << std::left << __tag_for_logging() \
+ << std::setw(0) << " : " \
#endif // UTILS_LOGGING_H_
#include <algorithm>
#include <cassert>
#include <cmath>
-#include <iostream>
-#include <ostream>
+
+#include "utils/logging.h"
namespace common_installer {
namespace utils {
FundamentalValue::FundamentalValue(double in_value)
: Value(TYPE_DOUBLE), double_value_(in_value) {
if (!std::isfinite(double_value_)) {
- std::cerr << "Non-finite (i.e. NaN or positive/negative infinity) "
- << "values cannot be represented in JSON";
+ LOG(ERROR) << "Non-finite (i.e. NaN or positive/negative infinity) "
+ << "values cannot be represented in JSON";
double_value_ = 0.0;
}
}
return new FundamentalValue(double_value_);
default:
- std::cerr << "Not reached.\n";
+ LOG(ERROR) << "Not reached";
return nullptr;
}
}
return GetAsDouble(&lhs) && other->GetAsDouble(&rhs) && lhs == rhs;
}
default:
- std::cerr << "Not reached.\n";
+ LOG(ERROR) << "Not reached";
return false;
}
}
#include <cstdio>
#include <cstdlib>
-#include <iostream>
#include <string>
#include "common/app_installer.h"
common_installer::Step::Status StepParse::process() {
if (!StepParse::Check(context_->unpack_directory())) {
- std::cout << "[Parse] No config.xml" << std::endl;
+ LOG(ERROR) << "No config.xml";
return common_installer::Step::Status::ERROR;
}
const ManifestData* data = nullptr;
const char* error = nullptr;
if (!ParseManifest(config_.c_str(), &data, &error)) {
- std::cout << "[Parse] Parse failed. " << error << std::endl;
+ LOG(ERROR) << "Parse failed. " << error;
if (!ReleaseData(data, error))
- std::cout << "[Parse] Release data failed." << std::endl;
+ LOG(ERROR) << " Release data failed.";
return common_installer::Step::Status::ERROR;
}
std::string(data->package));
fillManifest(data, context_->manifest_data());
- //--- Test ---
- std::cout << "[Parse] Read data -[ " << std::endl;
- std::cout << " package = " << data->package << std::endl;
- std::cout << " id = " << data->id << std::endl;
- std::cout << " name = " << data->name << std::endl;
- std::cout << " short_name = " << data->short_name << std::endl;
- std::cout << " version = " << data->version << std::endl;
- std::cout << " icon = " << data->icon << std::endl;
- std::cout << " api_version = " << data->api_version << std::endl;
- std::cout << " privileges -[" << std::endl;
+ LOG(DEBUG) << " Read data -[ ";
+ LOG(DEBUG) << " package = " << data->package;
+ LOG(DEBUG) << " id = " << data->id;
+ LOG(DEBUG) << " name = " << data->name;
+ LOG(DEBUG) << " short_name = " << data->short_name;
+ LOG(DEBUG) << " version = " << data->version;
+ LOG(DEBUG) << " icon = " << data->icon;
+ LOG(DEBUG) << " api_version = " << data->api_version;
+ LOG(DEBUG) << " privileges -[";
for (unsigned int i = 0; i < data->privilege_count; ++i)
- std::cout << " " << data->privilege_list[i] << std::endl;
- std::cout << " ]-" << std::endl;
- std::cout << "]-" << std::endl;
- //--- End Test ---
+ LOG(DEBUG) << " " << data->privilege_list[i];
+ LOG(DEBUG) << " ]-";
+ LOG(DEBUG) << "]-";
if (!ReleaseData(data, error)) {
- std::cout << "[Parse] Release data failed." << std::endl;
+ LOG(ERROR) << "Release data failed.";
return common_installer::Step::Status::ERROR;
}
boost::filesystem::path config = widget_path;
config /= "config.xml";
- std::cout << "[Parse] config.xml path: " << config << std::endl;
+ LOG(DEBUG) << "config.xml path: " << config;
if (!boost::filesystem::exists(config))
return false;
#include "common/app_installer.h"
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace wgt {
namespace parse {
boost::filesystem::path config_;
bool Check(const boost::filesystem::path& widget_path);
void fillManifest(const ManifestData* data, manifest_x* manifest);
+
+ SCOPE_LOG_TAG(Parse)
};
} // namespace parse
#include <boost/filesystem.hpp>
#include <cassert>
#include <cstring>
-#include <iostream>
#include <cstdio>
#include <string>
#include "common/utils.h"
-#define DBG(msg) std::cout << "[Symoblic Link] " << msg << std::endl;
-#define ERR(msg) std::cout << "[ERROR: Symoblic Link] " << msg << std::endl;
-
namespace wgt {
namespace symbolic_link {
uiapplication_x* ui = context_->manifest_data()->uiapplication;
serviceapplication_x* svc = context_->manifest_data()->serviceapplication;
if ((!ui) && (!svc)) {
- ERR("There is neither UI applications nor"
- << "Services applications described!\n");
+ LOG(ERROR) << "There is neither UI applications nor"
+ << "Services applications described!";
return Step::Status::ERROR;
}
// add ui-application element per ui application
fs::create_symlink(fs::path(WRT_LAUNCHER), exec_path, error);
if (error) {
- ERR("Failed to set symbolic link "
- << boost::system::system_error(error).what());
+ LOG(ERROR) << "Failed to set symbolic link "
+ << boost::system::system_error(error).what();
return Step::Status::ERROR;
}
}
fs::create_symlink(fs::path(WRT_LAUNCHER), exec_path, error);
if (error) {
- ERR("Failed to set symbolic link "
- << boost::system::system_error(error).what());
+ LOG(ERROR) << "Failed to set symbolic link "
+ << boost::system::system_error(error).what();
return Step::Status::ERROR;
}
}
- DBG("Successfully parse tizen manifest xml");
+ LOG(DEBUG) << "Successfully parse tizen manifest xml";
return Status::OK;
}
#include "common/app_installer.h"
#include "common/context_installer.h"
#include "common/step/step.h"
+#include "utils/logging.h"
namespace wgt {
namespace symbolic_link {
Status process() override;
Status clean() override;
Status undo() override;
+
+ SCOPE_LOG_TAG(SymbolicLink)
};
} // namespace symbolic_link
#include "widget-manifest-parser/application_data.h"
#include <cassert>
-#include <iostream>
#include <regex>
#include "utils/logging.h"
#include "widget-manifest-parser/manifest_handlers/permissions_handler.h"
-#include <iostream>
-
#include "utils/logging.h"
#include "utils/values.h"
#include "widget-manifest-parser/application_manifest_constants.h"
#include <regex>
#include <utility>
+#include "utils/logging.h"
#include "utils/values.h"
#include "widget-manifest-parser/application_manifest_constants.h"
if (app_info->id().find(app_info->package()) != 0) {
*error = "The application element property id "
"does not start with package.\n";
- fprintf(stderr, "app_info->id() = %s\n", app_info->id().c_str());
- fprintf(stderr, "app_info->package() = %s\n", app_info->package().c_str());
+ LOG(ERROR) << "app_info->id() = " << app_info->id();
+ LOG(ERROR) << "app_info->package() = " << app_info->package();
return false;
}
if (app_info->required_version().empty()) {
}
void WidgetInfo::SetShortName(const std::string& short_name) {
- fprintf(stderr, "setting short name: %s\n", short_name.c_str());
value_->SetString(kShortName, short_name);
}