Visual Computing Library  devel
Loading...
Searching...
No Matches
abstract_logger.h
1/*****************************************************************************
2 * VCLib *
3 * Visual Computing Library *
4 * *
5 * Copyright(C) 2021-2025 *
6 * Visual Computing Lab *
7 * ISTI - Italian National Research Council *
8 * *
9 * All rights reserved. *
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the Mozilla Public License Version 2.0 as published *
13 * by the Mozilla Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 * This program is distributed in the hope that it will be useful, *
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
19 * Mozilla Public License Version 2.0 *
20 * (https://www.mozilla.org/en-US/MPL/2.0/) for more details. *
21 ****************************************************************************/
22
23#ifndef VCL_BASE_LOGGER_ABSTRACT_LOGGER_H
24#define VCL_BASE_LOGGER_ABSTRACT_LOGGER_H
25
26#include <vclib/base/base.h>
27#include <vclib/base/pointers.h>
28
29#include <string>
30
31namespace vcl {
32
40{
41public:
42 // note: these constants have the _LOG suffix to avoid conflicts with some
43 // macros defined in windows.h headers
44 enum LogLevel {
45 ERROR_LOG = 0,
46 WARNING_LOG,
47 MESSAGE_LOG,
48 PROGRESS_LOG,
49 DEBUG_LOG
50 };
51
52 AbstractLogger() = default;
53
54 virtual void enableIndentation() = 0;
55
56 virtual void disableIndentation() = 0;
57
58 virtual void enablePrintPercentage() = 0;
59
60 virtual void disablePrintPercentage() = 0;
61
74 virtual void setPrintLevel(LogLevel level) = 0;
75
76 virtual void enablePrintMessageDuringProgress() = 0;
77
78 virtual void disablePrintMessageDuringProgress() = 0;
79
80 virtual void enablePrintTimer() = 0;
81
82 virtual void disablePrintTimer() = 0;
83
84 virtual void reset() = 0;
85
86 virtual void setMaxLineWidth(uint width) = 0;
87
88 virtual void startTimer() = 0;
89
90 virtual void stopTimer() = 0;
91
99 virtual double time() const = 0;
100
101 virtual void startNewTask(
102 double fromPerc,
103 double toPerc,
104 const std::string& action) = 0;
105
106 virtual void endTask(const std::string& action) = 0;
107
108 virtual double percentage() const = 0;
109
110 virtual void setPercentage(uint newPerc) = 0;
111
118 virtual void log(const std::string& msg) const = 0;
119
127 virtual void log(const std::string& msg, LogLevel lvl) const = 0;
128
136 virtual void log(uint perc, const std::string& msg) = 0;
137
146 virtual void log(uint perc, const std::string& msg, LogLevel lvl) = 0;
147
180 virtual void startProgress(
181 const std::string& msg,
182 uint progressSize,
183 uint percPrintProgress = 10,
184 uint startPerc = 0,
185 uint endPerc = 100) = 0;
186
210 virtual void endProgress() = 0;
211
241 virtual void progress(uint n) = 0;
242};
243
244/* Concepts */
245
258template<typename T>
259concept LoggerConcept = std::derived_from<RemoveRef<T>, AbstractLogger>;
260
261} // namespace vcl
262
263#endif // VCL_BASE_LOGGER_ABSTRACT_LOGGER_H
The AbstractLogger class is used as common ancestor class for all the logger types in the library.
Definition abstract_logger.h:40
virtual void log(const std::string &msg) const =0
Prints a message to the logger, with level LogLevel::PROGRESS and without modifying the current perce...
virtual double time() const =0
Returns the time passed since the last call to startTimer member function, or the time passed between...
virtual void endProgress()=0
Allows to easily manage progresses with the logger, along with the startProgress and progress member ...
virtual void startProgress(const std::string &msg, uint progressSize, uint percPrintProgress=10, uint startPerc=0, uint endPerc=100)=0
Allows to easily manage progresses with the logger, along with the progress and endProgress member fu...
virtual void setPrintLevel(LogLevel level)=0
Sets the maximum print level of the logger.
virtual void log(const std::string &msg, LogLevel lvl) const =0
Prints a message to the logger, with the given level and without modifying the current percentage.
virtual void progress(uint n)=0
Allows to easily manage progresses with the logger, along with the startProgress and endProgress memb...
virtual void log(uint perc, const std::string &msg, LogLevel lvl)=0
Prints a message to the logger, with the given level and with the given percentage.
virtual void log(uint perc, const std::string &msg)=0
Prints a message to the logger, with the level LogLevel::PROGRESS and with the given percentage.
A class representing a box in N-dimensional space.
Definition box.h:46
The LoggerConcept is satisfied if the type T is a valid Logger type.
Definition abstract_logger.h:259