ldap-config: Include phosphor-logging in source files
It is recommendded to include the phosphor-logging and related headers
in source files instead of header files.
Tested:
Build and unit test pass.
Change-Id: I880d8a3bf8dd850af300806da0d17357407632fd
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
diff --git a/phosphor-ldap-config/ldap_config.cpp b/phosphor-ldap-config/ldap_config.cpp
index 45968ac..d6cd6dd 100644
--- a/phosphor-ldap-config/ldap_config.cpp
+++ b/phosphor-ldap-config/ldap_config.cpp
@@ -7,6 +7,9 @@
#include <cereal/archives/binary.hpp>
#include <cereal/types/string.hpp>
#include <cereal/types/vector.hpp>
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/lg2.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/User/Common/error.hpp>
@@ -38,7 +41,6 @@
namespace fs = std::filesystem;
using Argument = xyz::openbmc_project::Common::InvalidArgument;
-using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
using NotAllowedArgument = xyz::openbmc_project::Common::NotAllowed;
using PrivilegeMappingExists = sdbusplus::xyz::openbmc_project::User::Common::
Error::PrivilegeMappingExists;
diff --git a/phosphor-ldap-config/ldap_config.hpp b/phosphor-ldap-config/ldap_config.hpp
index 1528512..6d5ee4e 100644
--- a/phosphor-ldap-config/ldap_config.hpp
+++ b/phosphor-ldap-config/ldap_config.hpp
@@ -4,12 +4,8 @@
#include "ldap_mapper_entry.hpp"
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <sdbusplus/server/object.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/Object/Enable/server.hpp>
#include <xyz/openbmc_project/User/Ldap/Config/server.hpp>
#include <xyz/openbmc_project/User/Ldap/Create/server.hpp>
@@ -24,8 +20,6 @@
namespace ldap
{
-using namespace phosphor::logging;
-using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using ConfigIface = sdbusplus::xyz::openbmc_project::User::Ldap::server::Config;
using EnableIface = sdbusplus::xyz::openbmc_project::Object::server::Enable;
using CreateIface = sdbusplus::server::object_t<
diff --git a/phosphor-ldap-config/ldap_config_mgr.cpp b/phosphor-ldap-config/ldap_config_mgr.cpp
index d2ef4e0..eec8579 100644
--- a/phosphor-ldap-config/ldap_config_mgr.cpp
+++ b/phosphor-ldap-config/ldap_config_mgr.cpp
@@ -3,6 +3,11 @@
#include "ldap_config.hpp"
#include "utils.hpp"
+#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <phosphor-logging/lg2.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
+
#include <filesystem>
#include <fstream>
#include <sstream>
@@ -17,10 +22,10 @@
constexpr auto ldapScheme = "ldap";
constexpr auto ldapsScheme = "ldaps";
+using namespace phosphor::logging;
using namespace sdbusplus::xyz::openbmc_project::Common::Error;
namespace fs = std::filesystem;
using Argument = xyz::openbmc_project::Common::InvalidArgument;
-using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
using NotAllowedArgument = xyz::openbmc_project::Common::NotAllowed;
using Line = std::string;
diff --git a/phosphor-ldap-config/ldap_config_mgr.hpp b/phosphor-ldap-config/ldap_config_mgr.hpp
index 3b48127..4bd013a 100644
--- a/phosphor-ldap-config/ldap_config_mgr.hpp
+++ b/phosphor-ldap-config/ldap_config_mgr.hpp
@@ -4,15 +4,12 @@
#include "ldap_config.hpp"
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/User/Ldap/Config/server.hpp>
#include <xyz/openbmc_project/User/Ldap/Create/server.hpp>
#include <string>
+
namespace phosphor
{
namespace ldap
@@ -25,8 +22,6 @@
static auto adDbusObjectPath =
std::string(LDAP_CONFIG_ROOT) + "/active_directory";
-using namespace phosphor::logging;
-using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using CreateIface = sdbusplus::server::object_t<
sdbusplus::xyz::openbmc_project::User::Ldap::server::Create>;
diff --git a/phosphor-ldap-config/ldap_mapper_entry.cpp b/phosphor-ldap-config/ldap_mapper_entry.cpp
index f903c1f..41b56eb 100644
--- a/phosphor-ldap-config/ldap_mapper_entry.cpp
+++ b/phosphor-ldap-config/ldap_mapper_entry.cpp
@@ -5,12 +5,6 @@
#include "ldap_config.hpp"
#include "ldap_mapper_serialize.hpp"
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/elog.hpp>
-#include <phosphor-logging/lg2.hpp>
-#include <xyz/openbmc_project/Common/error.hpp>
-#include <xyz/openbmc_project/User/Common/error.hpp>
-
#include <filesystem>
namespace phosphor
@@ -18,11 +12,6 @@
namespace ldap
{
-using namespace phosphor::logging;
-using InvalidArgument =
- sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
-using Argument = xyz::openbmc_project::Common::InvalidArgument;
-
LDAPMapperEntry::LDAPMapperEntry(sdbusplus::bus_t& bus, const char* path,
const char* filePath,
const std::string& groupName,
diff --git a/test/ldap_config_test.cpp b/test/ldap_config_test.cpp
index 6e4e6d2..febe687 100644
--- a/test/ldap_config_test.cpp
+++ b/test/ldap_config_test.cpp
@@ -5,8 +5,6 @@
#include <sys/types.h>
-#include <phosphor-logging/elog-errors.hpp>
-#include <phosphor-logging/lg2.hpp>
#include <sdbusplus/bus.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/User/Common/error.hpp>
@@ -24,12 +22,10 @@
{
namespace fs = std::filesystem;
namespace ldap_base = sdbusplus::xyz::openbmc_project::User::Ldap::server;
-using NotAllowed = sdbusplus::xyz::openbmc_project::Common::Error::NotAllowed;
-using NotAllowedArgument = xyz::openbmc_project::Common::NotAllowed;
-
-using Config = phosphor::ldap::Config;
+using namespace sdbusplus::xyz::openbmc_project::Common::Error;
using PrivilegeMappingExists = sdbusplus::xyz::openbmc_project::User::Common::
Error::PrivilegeMappingExists;
+using Config = phosphor::ldap::Config;
class TestLDAPConfig : public testing::Test
{