networkservice
Public Member Functions | List of all members
service::plugins::logger::ILogger Interface Referenceabstract

Print logs to help understanding what the service is doing. More...

#include "service/plugins/ILogger.h"

Inheritance diagram for service::plugins::logger::ILogger:
Inheritance graph
[legend]

Public Member Functions

 ILogger ()=default
 
virtual ~ILogger ()=default
 
 ILogger (const ILogger &)=delete
 
ILoggeroperator= (const ILogger &)=delete
 
 ILogger (ILogger &&)=delete
 
ILoggeroperator= (ILogger &&)=delete
 
virtual void debug (const std::string &message) const =0
 Print debug-level logs. More...
 
virtual void info (const std::string &message) const =0
 Print info-level logs. More...
 
virtual void warn (const std::string &message) const =0
 Print warning-level logs. More...
 
virtual void error (const std::string &message) const =0
 Print error-level logs. More...
 

Detailed Description

Print logs to help understanding what the service is doing.

This class is the high level interface that must be implemented by logger plugin. The core service depends on it and not on its implementation(s) to respect the Dependency Inversion Principle. The logger plugin is thus free to output logs wherever it wants:

Note
Copy contructor, copy-assignment operator, move constructor and move assignment operator are defined to be compliant with the "Rule of five".
One purpose in marking its member functions as const is that a const pointer or reference to ILogger can be used to call them. Thus, one can get "const ILogger*" or "const ILogger&" as input if neither a reset of the logger object, nor becoming an owner of it is necessary. Without this const, one would be forced to use "ILogger*" or "ILogger&" in that case thus have possibility to alter the logger object which is not what is expected.
See also
https://en.cppreference.com/w/cpp/language/rule_of_three
Author
Boubacar DIENE bouba.nosp@m.car..nosp@m.diene.nosp@m.@gma.nosp@m.il.co.nosp@m.m
Date
April 2020

Constructor & Destructor Documentation

◆ ILogger() [1/3]

service::plugins::logger::ILogger::ILogger ( )
default

Class constructor

◆ ~ILogger()

virtual service::plugins::logger::ILogger::~ILogger ( )
virtualdefault

Class destructor made virtual because it is used as base class by derived classes in logger plugin

◆ ILogger() [2/3]

service::plugins::logger::ILogger::ILogger ( const ILogger )
delete

Class copy constructor

◆ ILogger() [3/3]

service::plugins::logger::ILogger::ILogger ( ILogger &&  )
delete

Class move constructor

Member Function Documentation

◆ debug()

virtual void service::plugins::logger::ILogger::debug ( const std::string &  message) const
pure virtual

Print debug-level logs.

Debug logs are for debugging purposes; reserved to developer. It means that something normal and insignificant happened. Many problems can usually be resolved using a debugger but developers are sometimes stuck with these logs. It can be used to have some more details (compared to INFO) about what the application is doing and better isolate issues especially during the development phase.

General usage (not necessarily related to this project but can ease understanding):

  • Enter/Exit to/from a function
Parameters
messageThe log message to print
Note
debug-level logs can be enabled locally on the developer's computer or in an debug/engineering version.

Implemented in service::plugins::logger::Logger.

◆ error()

virtual void service::plugins::logger::ILogger::error ( const std::string &  message) const
pure virtual

Print error-level logs.

Error logs require a particular attention from the developer. They indicate that something unexpected occurred. The application faces a significant problem that can make it stop working and affect, in some way, the user experience. A fix might be expected.

General usage (not necessarily related to this project but can ease understanding):

  • An important component is not reachable while it should
  • Saving/restoring user preferences failed
  • Views not properly populated due to database connection failure
Parameters
messageThe log message to print
Note
error-level logs should be enabled in a release/production version.

Implemented in service::plugins::logger::Logger.

◆ info()

virtual void service::plugins::logger::ILogger::info ( const std::string &  message) const
pure virtual

Print info-level logs.

Informational logs the developer would like to see when analyzing an issue. It means that something normal but significant happened. To use this log level effectively, just ask yourself which kind of informations would be useful for diagnosing your application and to quite easily understand what it is doing.

General usage (not necessarily related to this project but can ease understanding):

  • Version of software in use to be sure it’s the expected one
  • System life cycle events (started, stopped, ...)
  • Session life cycle events (logged in, logged out, ...)
  • Usage information (what are users of currently doing?, ...)
Parameters
messageThe log message to print
Note
info-level logs can be enabled in a release/production version.

Implemented in service::plugins::logger::Logger.

◆ operator=() [1/2]

ILogger& service::plugins::logger::ILogger::operator= ( const ILogger )
delete

Class copy-assignment operator

◆ operator=() [2/2]

ILogger& service::plugins::logger::ILogger::operator= ( ILogger &&  )
delete

Class move-assignment operator

◆ warn()

virtual void service::plugins::logger::ILogger::warn ( const std::string &  message) const
pure virtual

Print warning-level logs.

Warning logs are for problems that are not necessarily important. They indicate that something unexpected occurred. The application faces a potential problem that does not affect the user experience and also does not prevent it from keeping working. Warning logs are sometimes a sign of an incoming failure.

General usage (not necessarily related to this project but can ease understanding):

  • Degraded service quality due to a weak Internet connection
  • More attempts as usual to access resources
  • File not found but default is used instead
Parameters
messageThe log message to print
Note
warning-level logs can be enabled in a release/production version.

Implemented in service::plugins::logger::Logger.


The documentation for this interface was generated from the following file: