Log.hxx 2.84 KB
Newer Older
1
/*
Max Kellermann's avatar
Max Kellermann committed
2
 * Copyright 2003-2017 The Music Player Daemon Project
3
 * http://www.musicpd.org
Warren Dukes's avatar
Warren Dukes committed
4 5 6 7 8 9 10 11 12 13
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
14 15 16 17
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Warren Dukes's avatar
Warren Dukes committed
18 19
 */

20 21
#ifndef MPD_LOG_HXX
#define MPD_LOG_HXX
Warren Dukes's avatar
Warren Dukes committed
22

23
#include "LogLevel.hxx"
24
#include "Compiler.h"
25

26
#include <exception>
27

28 29 30
class Domain;

void
Max Kellermann's avatar
Max Kellermann committed
31
Log(const Domain &domain, LogLevel level, const char *msg) noexcept;
32

Max Kellermann's avatar
Max Kellermann committed
33
gcc_printf(3,4)
34
void
Max Kellermann's avatar
Max Kellermann committed
35
LogFormat(const Domain &domain, LogLevel level, const char *fmt, ...) noexcept;
36 37

static inline void
Max Kellermann's avatar
Max Kellermann committed
38
LogDebug(const Domain &domain, const char *msg) noexcept
39 40 41 42
{
	Log(domain, LogLevel::DEBUG, msg);
}

Max Kellermann's avatar
Max Kellermann committed
43
gcc_printf(2,3)
44
void
Max Kellermann's avatar
Max Kellermann committed
45
FormatDebug(const Domain &domain, const char *fmt, ...) noexcept;
46 47

static inline void
Max Kellermann's avatar
Max Kellermann committed
48
LogInfo(const Domain &domain, const char *msg) noexcept
49 50 51 52
{
	Log(domain, LogLevel::INFO, msg);
}

Max Kellermann's avatar
Max Kellermann committed
53
gcc_printf(2,3)
54
void
Max Kellermann's avatar
Max Kellermann committed
55
FormatInfo(const Domain &domain, const char *fmt, ...) noexcept;
56

57
static inline void
Max Kellermann's avatar
Max Kellermann committed
58
LogDefault(const Domain &domain, const char *msg) noexcept
59 60 61 62 63 64
{
	Log(domain, LogLevel::DEFAULT, msg);
}

gcc_printf(2,3)
void
Max Kellermann's avatar
Max Kellermann committed
65
FormatDefault(const Domain &domain, const char *fmt, ...) noexcept;
66

67
static inline void
Max Kellermann's avatar
Max Kellermann committed
68
LogWarning(const Domain &domain, const char *msg) noexcept
69 70 71 72
{
	Log(domain, LogLevel::WARNING, msg);
}

Max Kellermann's avatar
Max Kellermann committed
73
gcc_printf(2,3)
74
void
Max Kellermann's avatar
Max Kellermann committed
75
FormatWarning(const Domain &domain, const char *fmt, ...) noexcept;
76 77

static inline void
Max Kellermann's avatar
Max Kellermann committed
78
LogError(const Domain &domain, const char *msg) noexcept
79 80 81 82
{
	Log(domain, LogLevel::ERROR, msg);
}

83
void
Max Kellermann's avatar
Max Kellermann committed
84
LogError(const std::exception &e) noexcept;
85 86

void
Max Kellermann's avatar
Max Kellermann committed
87
LogError(const std::exception &e, const char *msg) noexcept;
88

89 90
gcc_printf(2,3)
void
Max Kellermann's avatar
Max Kellermann committed
91
FormatError(const std::exception &e, const char *fmt, ...) noexcept;
92

93
void
Max Kellermann's avatar
Max Kellermann committed
94
LogError(const std::exception_ptr &ep) noexcept;
95 96

void
Max Kellermann's avatar
Max Kellermann committed
97
LogError(const std::exception_ptr &ep, const char *msg) noexcept;
98 99 100

gcc_printf(2,3)
void
Max Kellermann's avatar
Max Kellermann committed
101
FormatError(const std::exception_ptr &ep, const char *fmt, ...) noexcept;
102

Max Kellermann's avatar
Max Kellermann committed
103
gcc_printf(2,3)
104
void
Max Kellermann's avatar
Max Kellermann committed
105
FormatError(const Domain &domain, const char *fmt, ...) noexcept;
106

107
void
Max Kellermann's avatar
Max Kellermann committed
108
LogErrno(const Domain &domain, int e, const char *msg) noexcept;
109

110
void
Max Kellermann's avatar
Max Kellermann committed
111
LogErrno(const Domain &domain, const char *msg) noexcept;
Warren Dukes's avatar
Warren Dukes committed
112

Max Kellermann's avatar
Max Kellermann committed
113
gcc_printf(3,4)
114
void
Max Kellermann's avatar
Max Kellermann committed
115
FormatErrno(const Domain &domain, int e, const char *fmt, ...) noexcept;
116

Max Kellermann's avatar
Max Kellermann committed
117
gcc_printf(2,3)
118
void
Max Kellermann's avatar
Max Kellermann committed
119
FormatErrno(const Domain &domain, const char *fmt, ...) noexcept;
Warren Dukes's avatar
Warren Dukes committed
120

Eric Wong's avatar
Eric Wong committed
121
#endif /* LOG_H */