Libgourou

Libgourou Git Source Tree

Root/include/libgourou_log.h

1/*
2 Copyright 2021 Grégory Soutadé
3
4 This file is part of libgourou.
5
6 libgourou is free software: you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 libgourou is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with libgourou. If not, see <http://www.gnu.org/licenses/>.
18*/
19
20#ifndef _LIBGOUROU_LOG_H_
21#define _LIBGOUROU_LOG_H_
22
23#include <iostream>
24
25namespace gourou {
26 enum GOUROU_LOG_LEVEL {
27ERROR,
28WARN,
29INFO,
30DEBUG,
31TRACE
32 };
33
34 extern GOUROU_LOG_LEVEL logLevel;
35
36#define GOUROU_LOG(__lvl, __msg) if (__lvl <= gourou::logLevel) {std::cout << __msg << std::endl << std::flush;}
37#define GOUROU_LOG_FUNC() GOUROU_LOG(TRACE, __FUNCTION__ << "() @ " << __FILE__ << ":" << __LINE__)
38
39 /**
40 * @brief Get current log level
41 */
42 GOUROU_LOG_LEVEL getLogLevel();
43
44 /**
45 * @brief Set log level
46 */
47 void setLogLevel(GOUROU_LOG_LEVEL level);
48}
49
50#endif

Archive Download this file