iceoryx2
C++ Language Bindings
Loading...
Searching...
No Matches
log.hpp
Go to the documentation of this file.
1// Copyright (c) 2024 Contributors to the Eclipse Foundation
2//
3// See the NOTICE file(s) distributed with this work for additional
4// information regarding copyright ownership.
5//
6// This program and the accompanying materials are made available under the
7// terms of the Apache Software License 2.0 which is available at
8// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license
9// which is available at https://opensource.org/licenses/MIT.
10//
11// SPDX-License-Identifier: Apache-2.0 OR MIT
12
13#ifndef IOX2_LOG_HPP
14#define IOX2_LOG_HPP
15
16#include "iox2/log_level.hpp"
17
18namespace iox2 {
19
36class Log {
37 public:
38 Log() = default;
39 Log(const Log&) = default;
40 Log(Log&&) = default;
41 auto operator=(const Log&) -> Log& = default;
42 auto operator=(Log&&) -> Log& = default;
43 virtual ~Log() = default;
44
47 virtual void log(LogLevel log_level, const char* origin, const char* message) = 0;
48};
49
51void log(LogLevel log_level, const char* origin, const char* message);
52
54auto use_console_logger() -> bool;
55
57auto use_file_logger(const char* log_file) -> bool;
58
62auto set_logger(Log& logger) -> bool;
63
73
83
91auto set_log_level(LogLevel level) -> void;
92
95
96} // namespace iox2
97
98#endif
auto operator=(Log &&) -> Log &=default
Log()=default
virtual void log(LogLevel log_level, const char *origin, const char *message)=0
Log(const Log &)=default
Log(Log &&)=default
virtual ~Log()=default
auto operator=(const Log &) -> Log &=default
auto use_file_logger(const char *log_file) -> bool
Sets the file logger as default logger. Returns true if the logger was set, otherwise false.
auto get_log_level() -> LogLevel
Returns the current global log level of the application.
auto set_logger(Log &logger) -> bool
void log(LogLevel log_level, const char *origin, const char *message)
Adds a log message to the logger.
auto set_log_level_from_env_or_default() -> void
auto use_console_logger() -> bool
Sets the console logger as default logger. Returns true if the logger was set, otherwise false.
auto set_log_level_from_env_or(LogLevel level) -> void
auto set_log_level(LogLevel level) -> void