ORE Studio 0.0.4
Loading...
Searching...
No Matches
boost_severity.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_LOGGING_BOOST_SEVERITY_HPP
21#define ORES_LOGGING_BOOST_SEVERITY_HPP
22
23#include <string>
24#include <ostream>
25#include <stdexcept>
26#include "ores.logging/severity_level.hpp"
27
28namespace ores::logging {
29
41 trace,
42 debug,
43 info,
44 warn,
45 error
46};
47
55boost_severity to_boost_severity(const std::string& s);
56
64
72
78template<typename CharT, typename TraitsT>
79inline std::basic_ostream<CharT, TraitsT>&
80operator<<(std::basic_ostream<CharT, TraitsT>& stream, boost_severity level) {
81 switch(level) {
82 case boost_severity::trace: stream << "TRACE"; break;
83 case boost_severity::debug: stream << "DEBUG"; break;
84 case boost_severity::info: stream << "INFO"; break;
85 case boost_severity::warn: stream << "WARN"; break;
86 case boost_severity::error: stream << "ERROR"; break;
87 default:
88 throw std::invalid_argument("Invalid or unexpected severity level");
89 break;
90 }
91 return stream;
92}
93
94}
95
96#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
boost_severity to_boost_severity(const std::string &s)
Converts a string to boost_severity.
Definition boost_severity.cpp:26
boost_severity
Internal Boost.Log severity level enum.
Definition boost_severity.hpp:40
severity_level
Log severity levels following OpenTelemetry conventions.
Definition severity_level.hpp:34
severity_level to_domain_severity(boost_severity sev)
Converts internal boost_severity to domain severity_level.
Definition boost_severity.cpp:60
std::basic_ostream< CharT, TraitsT > & operator<<(std::basic_ostream< CharT, TraitsT > &stream, boost_severity level)
Inserter for boost_severity enum.
Definition boost_severity.hpp:80