libstorage-ng
Toggle main menu visibility
Loading...
Searching...
No Matches
Logger.h
1
/*
2
* Copyright (c) [2014-2015] Novell, Inc.
3
* Copyright (c) [2016-2020] SUSE LLC
4
*
5
* All Rights Reserved.
6
*
7
* This program is free software; you can redistribute it and/or modify it
8
* under the terms of version 2 of the GNU General Public License as published
9
* by the Free Software Foundation.
10
*
11
* This program is distributed in the hope that it will be useful, but WITHOUT
12
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14
* more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, contact Novell, Inc.
18
*
19
* To contact Novell about this file by physical or electronic mail, you may
20
* find current contact information at www.novell.com.
21
*/
22
23
24
#ifndef STORAGE_LOGGER_H
25
#define STORAGE_LOGGER_H
26
27
28
#include <string>
29
30
31
namespace
storage
32
{
33
37
enum class
LogLevel
{ DEBUG = 0, MILESTONE = 1, WARNING = 2, ERROR = 3 };
38
39
43
class
Logger
44
{
45
public
:
46
47
Logger() {}
48
virtual
~Logger() {}
49
54
virtual
bool
test
(
LogLevel
log_level,
const
std::string& component);
55
59
virtual
void
write
(
LogLevel
log_level,
const
std::string& component,
const
std::string& file,
60
int
line,
const
std::string& function,
const
std::string& content) = 0;
61
62
};
63
64
68
Logger
*
get_logger
();
69
70
75
void
set_logger
(
Logger
* logger);
76
77
82
Logger
*
get_stdout_logger
();
83
84
93
Logger
*
get_logfile_logger
(
const
std::string& filename =
"/var/log/libstorage.log"
);
94
95
99
class
Silencer
100
{
101
102
public
:
103
104
Silencer();
105
~Silencer();
106
107
void
turn_on();
108
void
turn_off();
109
110
static
bool
is_any_active() {
return
count > 0; }
111
112
private
:
113
114
bool
active;
115
116
static
int
count;
117
118
};
119
120
}
121
122
123
#endif
storage::Logger
The Logger class.
Definition
Logger.h:44
storage::Logger::test
virtual bool test(LogLevel log_level, const std::string &component)
Function to control whether a log line with level and component should be logged.
storage::Logger::write
virtual void write(LogLevel log_level, const std::string &component, const std::string &file, int line, const std::string &function, const std::string &content)=0
Function to log a line.
storage
The storage namespace.
Definition
Actiongraph.h:40
storage::LogLevel
LogLevel
Enum with log levels.
Definition
Logger.h:37
storage::get_logfile_logger
Logger * get_logfile_logger(const std::string &filename="/var/log/libstorage.log")
Returns a Logger that logs to the standard libstorage log file ("/var/log/libstorage....
storage::get_stdout_logger
Logger * get_stdout_logger()
Returns a Logger that logs to stdout/stderr.
storage::get_logger
Logger * get_logger()
Get the current logger object.
storage::set_logger
void set_logger(Logger *logger)
Set the current logger object.
storage
Utils
Logger.h
Generated by
1.17.0