Skip to content

Commit

Permalink
- Renamed ILogger class to ILoggerService.
Browse files Browse the repository at this point in the history
- Renamed LoggerGlog class to GlogLoggerService.
This change is for #134 and #137. This is to match design from #134 and #129.
  • Loading branch information
end2endzone committed Dec 28, 2023
1 parent 0e40b34 commit 1d61bcf
Show file tree
Hide file tree
Showing 12 changed files with 56 additions and 57 deletions.
4 changes: 2 additions & 2 deletions src/core/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ namespace shellanything
pmgr.SetProperty("application.path", mApplicationPath);
}

void App::SetLogger(ILogger* logger)
void App::SetLogger(ILoggerService* logger)
{
mLogger = logger;
}

ILogger* App::GetLogger()
ILoggerService* App::GetLogger()
{
return mLogger;
}
Expand Down
8 changes: 4 additions & 4 deletions src/core/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifndef SA_APP_H
#define SA_APP_H

#include "ILogger.h"
#include "ILoggerService.h"
#include "IRegistryService.h"

#include <string>
Expand Down Expand Up @@ -68,13 +68,13 @@ namespace shellanything
/// If a logger instance is already set, the caller must properly destroy the old instance.
/// </remarks>
/// <param name="logger">A valid instance of a ILogger.</param>
void SetLogger(ILogger* logger);
void SetLogger(ILoggerService* logger);

/// <summary>
/// Get the current application logger
/// </summary>
/// <returns>Returns a pointer to an ILogger instance. Returns NULL if no logger is set.</returns>
ILogger* GetLogger();
ILoggerService* GetLogger();

/// <summary>
/// Set the current application registry service.
Expand Down Expand Up @@ -141,7 +141,7 @@ namespace shellanything
private:
std::string mApplicationPath;

ILogger * mLogger;
ILoggerService * mLogger;
IRegistryService* mRegistry;
};

Expand Down
4 changes: 2 additions & 2 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ set(SHELLANYTHING_CORE_HEADER_FILES ""
${CMAKE_SOURCE_DIR}/src/core/SelectionContext.h
${CMAKE_SOURCE_DIR}/src/core/DefaultSettings.h
${CMAKE_SOURCE_DIR}/src/core/Icon.h
${CMAKE_SOURCE_DIR}/src/core/ILogger.h
${CMAKE_SOURCE_DIR}/src/core/ILoggerService.h
${CMAKE_SOURCE_DIR}/src/core/IRegistryService.h
${CMAKE_SOURCE_DIR}/src/core/LoggerHelper.h
${CMAKE_SOURCE_DIR}/src/core/Menu.h
Expand Down Expand Up @@ -52,7 +52,7 @@ add_library(sa.core SHARED
IAttributeValidator.h
IAttributeValidator.cpp
Icon.cpp
ILogger.cpp
ILoggerService.cpp
IRegistryService.cpp
LoggerHelper.cpp
InputBox.h
Expand Down
6 changes: 3 additions & 3 deletions src/core/ILogger.cpp → src/core/ILoggerService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@
* SOFTWARE.
*********************************************************************************/

#include "ILogger.h"
#include "ILoggerService.h"

namespace shellanything
{

ILogger::ILogger()
ILoggerService::ILoggerService()
{
}

ILogger::~ILogger()
ILoggerService::~ILoggerService()
{
}

Expand Down
17 changes: 8 additions & 9 deletions src/core/ILogger.h → src/core/ILoggerService.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
* SOFTWARE.
*********************************************************************************/

#ifndef SA_ILOGGER_H
#define SA_ILOGGER_H
#ifndef SA_ILOGGER_SERVICE_H
#define SA_ILOGGER_SERVICE_H

#include "shellanything/export.h"
#include "shellanything/config.h"
Expand All @@ -33,16 +33,16 @@ namespace shellanything
/// <summary>
/// Abstract logger class.
/// </summary>
class SHELLANYTHING_EXPORT ILogger
class SHELLANYTHING_EXPORT ILoggerService
{
public:
ILogger();
virtual ~ILogger();
ILoggerService();
virtual ~ILoggerService();

private:
// Disable and copy constructor, dtor and copy operator
ILogger(const ILogger&);
ILogger& operator=(const ILogger&);
ILoggerService(const ILoggerService&);
ILoggerService& operator=(const ILoggerService&);
public:

enum LOG_LEVEL
Expand Down Expand Up @@ -72,7 +72,6 @@ namespace shellanything

};


} //namespace shellanything

#endif //SA_IACTION_H
#endif //SA_ILOGGER_SERVICE_H
6 changes: 3 additions & 3 deletions src/core/LoggerHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@

namespace shellanything
{
LoggerHelper::LoggerHelper(ILogger::LOG_LEVEL level) :
LoggerHelper::LoggerHelper(ILoggerService::LOG_LEVEL level) :
mFilename(NULL),
mLine(0),
mLevel(level)
{
}

LoggerHelper::LoggerHelper(const char* filename, int line, ILogger::LOG_LEVEL level) :
LoggerHelper::LoggerHelper(const char* filename, int line, ILoggerService::LOG_LEVEL level) :
mFilename(filename),
mLine(line),
mLevel(level)
Expand All @@ -44,7 +44,7 @@ namespace shellanything
LoggerHelper::~LoggerHelper()
{
// Log the streamed content to the actual logger
ILogger * logger = App::GetInstance().GetLogger();;
ILoggerService * logger = App::GetInstance().GetLogger();;

if (logger)
{
Expand Down
10 changes: 5 additions & 5 deletions src/core/LoggerHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#ifndef SA_LOGGER_HELPER_H
#define SA_LOGGER_HELPER_H

#include "ILogger.h"
#include "ILoggerService.h"
#include "App.h"
#include <ostream>
#include <sstream>
Expand All @@ -39,8 +39,8 @@ namespace shellanything
class SHELLANYTHING_EXPORT LoggerHelper
{
public:
LoggerHelper(ILogger::LOG_LEVEL level);
LoggerHelper(const char * filename, int line, ILogger::LOG_LEVEL level);
LoggerHelper(ILoggerService::LOG_LEVEL level);
LoggerHelper(const char * filename, int line, ILoggerService::LOG_LEVEL level);
virtual ~LoggerHelper();

/// <summary>
Expand All @@ -59,14 +59,14 @@ namespace shellanything
LoggerHelper& operator<<(std::ostream& (*f)(std::ostream&));

private:
ILogger::LOG_LEVEL mLevel;
ILoggerService::LOG_LEVEL mLevel;
const char* mFilename;
int mLine;
std::stringstream mSS;
};

#ifndef SA_LOG
#define SA_LOG(expr) (::shellanything::LoggerHelper(__FILE__, __LINE__, ::shellanything::ILogger::LOG_LEVEL_##expr))
#define SA_LOG(expr) (::shellanything::LoggerHelper(__FILE__, __LINE__, ::shellanything::ILoggerService::LOG_LEVEL_##expr))
#endif

} //namespace shellanything
Expand Down
4 changes: 2 additions & 2 deletions src/logger/glog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
add_library(sa.logger.glog SHARED
dllmain.cpp
GlogLoggerService.cpp
GlogLoggerService.h
GlogUtils.cpp
GlogUtils.h
LoggerGlog.cpp
LoggerGlog.h
)

# Force CMAKE_DEBUG_POSTFIX for executables
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* SOFTWARE.
*********************************************************************************/

#include "LoggerGlog.h"
#include "GlogLoggerService.h"

#pragma warning( push )
#pragma warning( disable: 4355 ) // glog\install_dir\include\glog/logging.h(1167): warning C4355: 'this' : used in base member initializer list
Expand All @@ -32,41 +32,41 @@
namespace shellanything
{

inline ::google::LogSeverity to_severity(const ILogger::LOG_LEVEL& level)
inline ::google::LogSeverity to_severity(const ILoggerService::LOG_LEVEL& level)
{
switch (level)
{
default:
case ILogger::LOG_LEVEL_DEBUG:
case ILogger::LOG_LEVEL_INFO:
case ILoggerService::LOG_LEVEL_DEBUG:
case ILoggerService::LOG_LEVEL_INFO:
return ::google::GLOG_INFO;
break;
case ILogger::LOG_LEVEL_WARNING:
case ILoggerService::LOG_LEVEL_WARNING:
return ::google::GLOG_WARNING;
break;
case ILogger::LOG_LEVEL_ERROR:
case ILoggerService::LOG_LEVEL_ERROR:
return ::google::GLOG_ERROR;
break;
case ILogger::LOG_LEVEL_FATAL:
case ILoggerService::LOG_LEVEL_FATAL:
return ::google::GLOG_FATAL;
break;
};
}

LoggerGlog::LoggerGlog()
GlogLoggerService::GlogLoggerService()
{
}

LoggerGlog::~LoggerGlog()
GlogLoggerService::~GlogLoggerService()
{
}

void LoggerGlog::LogMessage(const char* filename, int line, const ILogger::LOG_LEVEL& level, const char* message)
void GlogLoggerService::LogMessage(const char* filename, int line, const ILoggerService::LOG_LEVEL& level, const char* message)
{
::google::LogMessage(filename, line, to_severity(level)).stream() << message;
}

void LoggerGlog::LogMessage(const ILogger::LOG_LEVEL& level, const char* message)
void GlogLoggerService::LogMessage(const ILoggerService::LOG_LEVEL& level, const char* message)
{
::google::LogMessage(__FILE__, __LINE__, to_severity(level)).stream() << message;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,27 @@
* SOFTWARE.
*********************************************************************************/

#ifndef SA_LOGGER_GLOG_H
#define SA_LOGGER_GLOG_H
#ifndef SA_GLOG_LOGGER_SERVICE_H
#define SA_GLOG_LOGGER_SERVICE_H

#include "sa_glog_export.h"
#include "ILogger.h"
#include "ILoggerService.h"

namespace shellanything
{
/// <summary>
/// Abstract logger class.
/// </summary>
class SA_GLOG_EXPORT LoggerGlog : public virtual ILogger
class SA_GLOG_EXPORT GlogLoggerService : public virtual ILoggerService
{
public:
LoggerGlog();
virtual ~LoggerGlog();
GlogLoggerService();
virtual ~GlogLoggerService();

private:
// Disable and copy constructor, dtor and copy operator
LoggerGlog(const LoggerGlog&);
LoggerGlog& operator=(const LoggerGlog&);
GlogLoggerService(const GlogLoggerService&);
GlogLoggerService& operator=(const GlogLoggerService&);
public:

/// <summary>
Expand All @@ -52,17 +52,17 @@ namespace shellanything
/// <param name="line">The line number that producing this message.</param>
/// <param name="level">The log level of the message.</param>
/// <param name="message">The actual message.</param>
virtual void LogMessage(const char* filename, int line, const ILogger::LOG_LEVEL & level, const char* message);
virtual void LogMessage(const char* filename, int line, const ILoggerService::LOG_LEVEL & level, const char* message);

/// <summary>
/// Send a message to this logger.
/// </summary>
/// <param name="level">The log level of the message.</param>
/// <param name="message">The actual message.</param>
virtual void LogMessage(const ILogger::LOG_LEVEL & level, const char* message);
virtual void LogMessage(const ILoggerService::LOG_LEVEL & level, const char* message);

};

} //namespace shellanything

#endif //SA_LOGGER_GLOG_H
#endif //SA_GLOG_LOGGER_SERVICE_H
4 changes: 2 additions & 2 deletions src/shellextension/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#include "Win32Utils.h"
#include "GlogUtils.h"

#include "LoggerGlog.h"
#include "GlogLoggerService.h"
#include "RegistryService.h"

#include "rapidassist/undef_windows_macros.h"
Expand Down Expand Up @@ -364,7 +364,7 @@ extern "C" int APIENTRY DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpRe
glog::InitGlog();

// Setup an active logger in ShellAnything's core.
shellanything::ILogger* logger = new shellanything::LoggerGlog();
shellanything::ILoggerService* logger = new shellanything::GlogLoggerService();
app.SetLogger(logger);

// Setup an active registry service in ShellAnything's core.
Expand Down
6 changes: 3 additions & 3 deletions src/tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@
#include "PropertyManager.h"
#include "Workspace.h"

#include "ILogger.h"
#include "ILoggerService.h"
#include "App.h"
#include "LoggerHelper.h"
#include "LoggerGlog.h"
#include "GlogLoggerService.h"
#include "RegistryService.h"
#include "ConfigManager.h"

Expand Down Expand Up @@ -123,7 +123,7 @@ int main(int argc, char** argv)
glog::InitGlog();

// Setup an active logger in ShellAnything's core.
shellanything::ILogger* logger = new shellanything::LoggerGlog();
shellanything::ILoggerService* logger = new shellanything::GlogLoggerService();
app.SetLogger(logger);

// Setup an active registry service in ShellAnything's core.
Expand Down

0 comments on commit 1d61bcf

Please sign in to comment.