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 virtual ~AbstractLogger() = default;
54
55 virtual void enableIndentation() = 0;
56
57 virtual void disableIndentation() = 0;
58
59 virtual void enablePrintPercentage() = 0;
60
61 virtual void disablePrintPercentage() = 0;
62
75 virtual void setPrintLevel(LogLevel level) = 0;
76
77 virtual void enablePrintMessageDuringProgress() = 0;
78
79 virtual void disablePrintMessageDuringProgress() = 0;
80
81 virtual void enablePrintTimer() = 0;
82
83 virtual void disablePrintTimer() = 0;
84
85 virtual void reset() = 0;
86
87 virtual void setMaxLineWidth(uint width) = 0;
88
89 virtual void startTimer() = 0;
90
91 virtual void stopTimer() = 0;
92
100 virtual double time() const = 0;
101
102 virtual void startNewTask(
103 double fromPerc,
104 double toPerc,
105 const std::string& action) = 0;
106
107 virtual void endTask(const std::string& action) = 0;
108
109 virtual double percentage() const = 0;
110
111 virtual void setPercentage(uint newPerc) = 0;
112
119 virtual void log(const std::string& msg) const = 0;
120
128 virtual void log(const std::string& msg, LogLevel lvl) const = 0;
129
137 virtual void log(uint perc, const std::string& msg) = 0;
138
147 virtual void log(uint perc, const std::string& msg, LogLevel lvl) = 0;
148
181 virtual void startProgress(
182 const std::string& msg,
183 uint progressSize,
184 uint percPrintProgress = 10,
185 uint startPerc = 0,
186 uint endPerc = 100) = 0;
187
211 virtual void endProgress() = 0;
212
242 virtual void progress(uint n) = 0;
243};
244
245/* Concepts */
246
259template<typename T>
260concept LoggerConcept = std::derived_from<RemoveRef<T>, AbstractLogger>;
261
262} // namespace vcl
263
264#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:260