This repository has been archived by the owner on May 4, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Log.h
57 lines (52 loc) · 1.27 KB
/
Log.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#ifndef LOG_H
#define LOG_H
/**
* \file
* \brief Definicja klasy Log, wyświetlającej informacje o działaniu programu.
*
* Plik ten jest częścią projektu currency_calc.
*/
#include <iostream>
#include <string>
/**
* \brief Klasa wyświetlania powiadomień.
*
* Klasa typu <b>singleton</b> wyświetlająca powiadomienia na standardowym wyjściu,
* gdy program zostanie uruchomiony z opcją \e --verbose. \e
*/
class Log
{
private:
static Log* instance; ///< Instancja klasy
bool skip_log; ///< Flaga pomijania powiadomień
/**
* \brief Prywatny konstruktor.
*/
Log();
public:
/**
* \brief Zwraca instancję obiektu.
*/
static Log& get();
/**
* \brief Wyświetla powiadomienie.
*/
template <typename T> void log(const T& line)
{
if (!skip_log)
std::cout << line;
}
/**
* \brief Przeciążony operator<< wyświetlający powiadomienie.
*/
template <typename T> Log& operator<<(const T& line)
{
log(line);
return *this;
}
/**
* \brief Ustawia flagę pomijania powiadomień.
*/
void skipLog(bool skip);
};
#endif // LOG_H