ifw-daq 3.1.0
IFW Data Acquisition modules
Loading...
Searching...
No Matches
log4cplus.hpp
Go to the documentation of this file.
1/**
2 * @file
3 * @ingroup daq_libdaq
4 * @copyright (c) Copyright ESO 2022
5 * All Rights Reserved
6 * ESO (eso.org) is an Intergovernmental Organisation, and therefore special legal conditions apply.
7 *
8 * @brief Declaration of log4cplus helpers
9 */
10#ifndef DAQ_LOG4CPLUS_HPP
11#define DAQ_LOG4CPLUS_HPP
12
13#include <cstdint>
14#include <iosfwd>
15
16#include <log4cplus/loglevel.h>
17
18namespace daq {
19
20/**
21 * ly typed log4cplus::LogLevel (which is an alias to int)
22 */
23struct LogLevel {
24 log4cplus::LogLevel value;
25};
26
27/**
28 * Parse log level from string.
29 */
30std::istream& operator>>(std::istream& is, LogLevel& level);
31
32/**
33 * Format log level to stream.
34 */
35std::ostream& operator<<(std::ostream& os, LogLevel level);
36
37/**
38 * Trim string from whitespace (' ', '\n')
39 */
40class Trim {
41public:
42 static constexpr std::string_view WHITESPACE = " \n\t";
43 enum : std::uint8_t {
44 Right = 1 << 2,
45 };
46 /**
47 * Construct from exception derived from std::exception.
48 */
49 explicit Trim(std::string_view str, std::uint8_t spec = Right) noexcept
50
51 : m_str(str), m_spec(spec){};
52
53 /**
54 * Formats string by trimming as
55 *
56 * @param os output stream to output to.
57 * @param reporter Reporter adapter to format.
58 * @returns os
59 */
60 friend std::ostream& operator<<(std::ostream& os, Trim const& trim);
61
62private:
63 std::string_view m_str;
64 std::uint8_t m_spec;
65};
66} // namespace daq
67
68#endif // #ifndef DAQ_LOG4CPLUS_HPP
Trim string from whitespace (' ', ' ')
Definition: log4cplus.hpp:40
friend std::ostream & operator<<(std::ostream &os, Trim const &trim)
Formats string by trimming as.
Definition: log4cplus.cpp:35
static constexpr std::string_view WHITESPACE
Definition: log4cplus.hpp:42
Trim(std::string_view str, std::uint8_t spec=Right) noexcept
Construct from exception derived from std::exception.
Definition: log4cplus.hpp:49
std::istream & operator>>(std::istream &is, LogLevel &level)
Parse log level from string.
Definition: log4cplus.cpp:17
std::ostream & operator<<(std::ostream &os, AsyncProcessIf const &proc)
Formats proc representation in the form [<pid>] <args>
log4cplus::LogLevel value
Definition: log4cplus.hpp:24
ly typed log4cplus::LogLevel (which is an alias to int)
Definition: log4cplus.hpp:23