author | František Kučera <franta-hg@frantovo.cz> |
Mon, 04 Jan 2021 15:45:12 +0100 | |
branch | v_0 |
changeset 12 | 15d87fdd6e6c |
permissions | -rw-r--r-- |
12
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
1 |
/** |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
2 |
* DJM-Fix |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
3 |
* Copyright © 2020 František Kučera (Frantovo.cz, GlobalCode.info) |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
4 |
* |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
5 |
* This program is free software: you can redistribute it and/or modify |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
7 |
* the Free Software Foundation, version 3 of the License. |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
8 |
* |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
13 |
* |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
15 |
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
16 |
*/ |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
17 |
#pragma once |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
18 |
|
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
19 |
#include <iostream> |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
20 |
|
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
21 |
namespace djmfix { |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
22 |
namespace logging { |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
23 |
|
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
24 |
enum class Level { |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
25 |
SEVERE, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
26 |
WARNING, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
27 |
INFO, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
28 |
CONFIG, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
29 |
FINE, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
30 |
FINER, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
31 |
FINEST, |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
32 |
}; |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
33 |
|
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
34 |
class Logger { |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
35 |
public: |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
36 |
virtual ~Logger() = default; |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
37 |
virtual void log(Level level, const std::string& message) = 0; |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
38 |
}; |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
39 |
|
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
40 |
Logger* create(std::ostream& output, Level minLevel); |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
41 |
Logger* blackhole(); |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
42 |
|
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
43 |
} |
15d87fdd6e6c
use Logger instead of messing with STDIO directly
František Kučera <franta-hg@frantovo.cz>
parents:
diff
changeset
|
44 |
} |