UMPS
The University of Utah Seismograph Stations Message Passing System.
Introduction

Introduction to the logging section.

Collaboration diagram for Introduction:

Introduction to the logging section.

Logging

As applications move into production, we cannot be required to stare at a terminal all day so as to monitor the program output. This activity is not only monotonous but it is typically pointless since production applications generally work just fine and therefore have nothing to report. For these reasons, it is important that production code, which will likely run as a daemon process, have a logging facility. The logging facilities provided by UMPS build upon SpdLog. While SpdLog has more options, we limit our logging to just four levels:
#ifndef UMPS_LOGGING_LEVEL_HPP
#define UMPS_LOGGING_LEVEL_HPP
#include <cstdint>
namespace UMPS::Logging
{
enum class Level : uint32_t
{
NONE = 0,
ERROR = 1,
WARN = 2,
INFO = 3,
DEBUG = 4,
None = NONE,
Error = ERROR,
Warn = WARN,
Info = INFO,
Debug = DEBUG
};
}
#endif
Defines the logging level.
The following describes what type of behavior you should expect from UMPS for a given message
  • Error is for error messages. Error messages typically correspond to an UMPS function throwing an error. When UMPS throws an error you will have to deal with it or your application will crash.
  • Warn is for warning messages. Warning messages typically correspond to UMPS function making a decision and lurching forward. Warnings are not great and should be dealt with in a timely manner.
  • Info is for information messages. Information messages typically correspond to a successful event that UMPS deems important like a connection being established. Info is the default logging level for the loggers provided by UMPS.
  • Debug is for debugging messages. Debug messages are extraordinarily granular and typically only useful while actively debugging a program.
Should you find the provided loggers insufficient you can create your own logger. In this case, you will derive from the ILog base class:
#ifndef UMPS_LOGGING_LOG_HPP
#define UMPS_LOGGING_LOG_HPP
#include <string>
#include "umps/logging/level.hpp"
namespace UMPS::Logging
{
class ILog
{
public:
virtual ~ILog() = default;
[[nodiscard]] virtual Level getLevel() const noexcept = 0;
virtual void error(const std::string &message) = 0;
virtual void warn(const std::string &message) = 0;
virtual void info(const std::string &message) = 0;
virtual void debug(const std::string &message) = 0;
};
}
#endif
virtual Level getLevel() const noexcept=0
virtual void info(const std::string &message)=0
Writes an info message.
virtual void error(const std::string &message)=0
Writes an error message.
virtual void warn(const std::string &message)=0
Writes a warning message.
virtual void debug(const std::string &message)=0
Writes a debug message.
Again, we are describing an abstract base class where you must
  • report on the logger's logging level.
  • define an action for an error message.
  • define an action for a warning message.
  • define an action for an info message.
  • define an action for a debug message.
By using dependency injection in constructors will then be enable you to permeate your logger through UMPS.