AnCH Framework 0.2
Another C++ Hack: C++23 utility libraries
Loading...
Searching...
No Matches
logger.hpp
1/*
2 ANCH Framework: ANother C++ Hack is a C++ framework based on C++23 standard
3 Copyright (C) 2012 Vincent Lachenal
4
5 This file is part of ANCH Framework.
6
7 ANCH Framework is free software: you can redistribute it and/or modify
8 it under the terms of the GNU Lesser General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 ANCH Framework is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU Lesser General Public License for more details.
16
17 You should have received a copy of the GNU Lesser General Public License
18 along with ANCH Framework. If not, see <https://www.gnu.org/licenses/>.
19*/
20#pragma once
21
22#include "anch-log-export.hpp"
23
24#include <iostream>
25#include <sstream>
26#include <vector>
27
28#include "log/levels.hpp"
29#include "log/writer.hpp"
30
31namespace anch::log {
32
47 class ANCH_LOG_EXPORT Logger {
48 // Attributes +
49 private:
51 std::string _name;
52
54 anch::log::Level _level;
55
57 std::vector<anch::log::Writer*> _writers;
58 // Attributes -
59
60 // Constructors +
61 public:
69 Logger(const std::string& name,
70 const anch::log::Level level,
71 const std::vector<anch::log::Writer*>& writers);
72 // Constructors -
73
74 // Destructor +
78 virtual ~Logger();
79 // Destructor -
80
81 // Methods +
82 public:
91 template<typename T, typename... Q>
92 void trace(const T& value, const Q&... values) const noexcept;
93
102 template<typename T, typename... Q>
103 void debug(const T& value, const Q&... values) const noexcept;
104
113 template<typename T, typename... Q>
114 void info(const T& value, const Q&... values) const noexcept;
115
124 template<typename T, typename... Q>
125 void warn(const T& value, const Q&... values) const noexcept;
126
135 template<typename T, typename... Q>
136 void error(const T& value, const Q&... values) const noexcept;
137
146 template<typename T, typename... Q>
147 void fatal(const T& value, const Q&... values) const noexcept;
148
158 bool isEnabled(const anch::log::Level& level) const noexcept;
159
170 void write(const anch::log::Level& level, const std::string& message) const noexcept;
171
172 private:
181 template<typename T>
182 void log(const Level& level,
183 std::ostringstream& out,
184 const T& value) const noexcept;
185
193 template<typename T, typename... Q>
194 void log(const Level& level,
195 const T& value,
196 const Q&... values) const noexcept;
197
206 template<typename T, typename... Q>
207 void log(const Level& level,
208 std::ostringstream& out,
209 const T& value,
210 const Q&... values) const noexcept;
211 // Methods -
212
213 };
214
215}
216
217#include "log/impl/logger.hpp"
void info(const T &value, const Q &... values) const noexcept
void fatal(const T &value, const Q &... values) const noexcept
bool isEnabled(const anch::log::Level &level) const noexcept
void trace(const T &value, const Q &... values) const noexcept
void error(const T &value, const Q &... values) const noexcept
Logger(const std::string &name, const anch::log::Level level, const std::vector< anch::log::Writer * > &writers)
void warn(const T &value, const Q &... values) const noexcept
void write(const anch::log::Level &level, const std::string &message) const noexcept
void debug(const T &value, const Q &... values) const noexcept
AnCH logging library namespace.
Definition constants.hpp:26
Level
Definition levels.hpp:43