2018-02-04 03:22:01 +01:00
|
|
|
// Matrix Construct
|
|
|
|
//
|
|
|
|
// Copyright (C) Matrix Construct Developers, Authors & Contributors
|
|
|
|
// Copyright (C) 2016-2018 Jason Volk <jason@zemos.net>
|
|
|
|
//
|
|
|
|
// Permission to use, copy, modify, and/or distribute this software for any
|
|
|
|
// purpose with or without fee is hereby granted, provided that the above
|
|
|
|
// copyright notice and this permission notice is present in all copies. The
|
|
|
|
// full license for this software is available in the LICENSE file.
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-13 05:05:54 +02:00
|
|
|
#pragma once
|
|
|
|
#define HAVE_IRCD_LOGGER_H
|
2007-01-25 07:40:21 +01:00
|
|
|
|
2016-08-26 06:38:15 +02:00
|
|
|
// windows.h #define conflicts with our facility
|
|
|
|
#ifdef HAVE_WINDOWS_H
|
|
|
|
#undef ERROR
|
|
|
|
#endif
|
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd
|
|
|
|
{
|
|
|
|
const char *smalldate(const time_t &);
|
|
|
|
}
|
|
|
|
|
2017-09-12 18:37:44 +02:00
|
|
|
/// Logging system
|
2017-08-28 23:51:22 +02:00
|
|
|
namespace ircd::log
|
|
|
|
{
|
|
|
|
enum facility :int;
|
|
|
|
struct log;
|
2018-04-23 23:14:26 +02:00
|
|
|
struct vlog;
|
2018-04-24 02:44:49 +02:00
|
|
|
struct logf;
|
2018-04-23 23:14:26 +02:00
|
|
|
struct mark;
|
2017-08-28 23:51:22 +02:00
|
|
|
struct console_quiet;
|
|
|
|
|
2018-01-21 10:17:33 +01:00
|
|
|
struct critical;
|
|
|
|
struct error;
|
2018-03-15 20:20:21 +01:00
|
|
|
struct derror;
|
2018-01-21 10:17:33 +01:00
|
|
|
struct warning;
|
2018-03-15 20:20:21 +01:00
|
|
|
struct dwarning;
|
2018-01-21 10:17:33 +01:00
|
|
|
struct notice;
|
|
|
|
struct info;
|
|
|
|
struct debug;
|
2017-08-28 23:51:22 +02:00
|
|
|
|
2018-04-24 00:46:09 +02:00
|
|
|
extern log star; // "*", '*'
|
|
|
|
extern log general; // "ircd", 'G'
|
|
|
|
|
2018-12-12 17:47:13 +01:00
|
|
|
string_view reflect(const facility &);
|
|
|
|
facility reflect(const string_view &);
|
|
|
|
|
2018-04-24 00:46:09 +02:00
|
|
|
// The mask is the list of named loggers to allow; an empty mask disallows
|
|
|
|
// all loggers. An empty unmask allows all loggers. An unmask of a logger
|
|
|
|
// that wasn't masked has no effect. Provided string_views don't have to
|
|
|
|
// remain valid after call.
|
|
|
|
void console_unmask(const vector_view<string_view> & = {});
|
|
|
|
void console_mask(const vector_view<string_view> & = {});
|
|
|
|
|
|
|
|
// This suite adjusts the output for an entire level.
|
2018-02-22 01:11:24 +01:00
|
|
|
bool console_enabled(const facility &);
|
|
|
|
void console_disable(const facility &);
|
|
|
|
void console_enable(const facility &);
|
2018-12-06 04:00:10 +01:00
|
|
|
void console_disable();
|
|
|
|
void console_enable();
|
2018-02-22 01:11:24 +01:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
void flush();
|
|
|
|
void close();
|
|
|
|
void open();
|
|
|
|
|
|
|
|
void init();
|
|
|
|
void fini();
|
|
|
|
}
|
2016-08-26 06:38:15 +02:00
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
enum ircd::log::facility
|
|
|
|
:int
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-03-15 20:20:21 +01:00
|
|
|
CRITICAL = 0, ///< Catastrophic/unrecoverable; program is in a compromised state.
|
|
|
|
ERROR = 1, ///< Things that shouldn't happen; user impacted and should know.
|
2018-05-22 01:14:59 +02:00
|
|
|
WARNING = 2, ///< Non-impacting undesirable behavior user should know about.
|
|
|
|
NOTICE = 3, ///< An infrequent important message with neutral or positive news.
|
|
|
|
INFO = 4, ///< A more frequent message with good news.
|
|
|
|
DERROR = 5, ///< An error but only worthy of developers in debug mode.
|
|
|
|
DWARNING = 6, ///< A warning but only for developers in debug mode.
|
2018-03-15 20:20:21 +01:00
|
|
|
DEBUG = 7, ///< Maximum verbosity for developers.
|
2016-08-26 06:38:15 +02:00
|
|
|
_NUM_
|
|
|
|
};
|
|
|
|
|
2018-04-23 23:48:48 +02:00
|
|
|
/// A named logger. Create an instance of this to help categorize log messages.
|
|
|
|
/// All messages sent to this logger will be prefixed with the given name.
|
|
|
|
/// Admins will use this to create masks to filter log messages. Instances
|
|
|
|
/// of this class are registered with instance_list for de-confliction and
|
|
|
|
/// iteration, so the recommended duration of this class is static.
|
2018-04-23 23:23:29 +02:00
|
|
|
struct ircd::log::log
|
2018-04-23 23:48:48 +02:00
|
|
|
:instance_list<log>
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
string_view name; // name of this logger
|
|
|
|
char snote; // snomask character
|
|
|
|
bool cmasked {true}; // currently in the console mask (enabled)
|
|
|
|
bool fmasked {true}; // currently in the file mask (enabled)
|
2016-08-26 06:38:15 +02:00
|
|
|
|
|
|
|
public:
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void operator()(const facility &, const string_view &fmt, args&&...);
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 0
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void critical(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void critical(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 1
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void error(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void error(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 2
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void warning(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void warning(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 3
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void notice(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void notice(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 4
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void info(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void info(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
2018-03-24 22:51:10 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 5
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void derror(const string_view &fmt, args&&...);
|
2018-03-24 22:51:10 +01:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void derror(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 6
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void dwarning(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void dwarning(const string_view &fmt, ...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 7
|
2018-12-10 22:00:33 +01:00
|
|
|
template<class... args> void debug(const string_view &fmt, args&&...);
|
2018-05-22 01:55:10 +02:00
|
|
|
#else // Required for DCE in gcc 6.3.0 20170519
|
2018-12-10 22:00:33 +01:00
|
|
|
void debug(const string_view &fmt, ...);
|
2018-03-24 22:51:10 +01:00
|
|
|
#endif
|
2016-08-26 06:38:15 +02:00
|
|
|
|
2018-04-23 23:48:48 +02:00
|
|
|
log(const string_view &name, const char &snote = '\0');
|
2018-04-24 00:46:09 +02:00
|
|
|
|
|
|
|
static bool exists(const log *const &ptr);
|
|
|
|
static log *find(const string_view &name);
|
|
|
|
static log *find(const char &snote);
|
2016-08-26 06:38:15 +02:00
|
|
|
};
|
|
|
|
|
2018-04-23 23:14:26 +02:00
|
|
|
struct ircd::log::vlog
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
vlog(const log &log, const facility &, const string_view &fmt, const va_rtti &ap);
|
2018-04-23 23:14:26 +02:00
|
|
|
};
|
|
|
|
|
2018-04-24 02:44:49 +02:00
|
|
|
struct ircd::log::logf
|
|
|
|
{
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
logf(const log &log, const facility &facility, const string_view &fmt, args&&... a)
|
2018-04-24 02:44:49 +02:00
|
|
|
{
|
|
|
|
vlog(log, facility, fmt, va_rtti{std::forward<args>(a)...});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-04-23 23:14:26 +02:00
|
|
|
struct ircd::log::mark
|
|
|
|
{
|
|
|
|
mark(const facility &, const string_view &msg = {});
|
|
|
|
mark(const string_view &msg = {});
|
|
|
|
};
|
|
|
|
|
2017-08-28 23:51:22 +02:00
|
|
|
struct ircd::log::console_quiet
|
2016-09-07 01:31:29 +02:00
|
|
|
{
|
|
|
|
console_quiet(const bool &showmsg = true);
|
|
|
|
~console_quiet();
|
|
|
|
};
|
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 7
|
2018-01-21 10:17:33 +01:00
|
|
|
struct ircd::log::debug
|
2017-03-18 04:24:25 +01:00
|
|
|
{
|
2018-01-21 10:17:33 +01:00
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
debug(const log &log, const string_view &fmt, args&&... a)
|
2018-01-21 10:17:33 +01:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(log, facility::DEBUG, fmt, va_rtti{std::forward<args>(a)...});
|
2018-01-21 10:17:33 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
debug(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(general, facility::DEBUG, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-04-23 23:17:38 +02:00
|
|
|
};
|
|
|
|
#else
|
|
|
|
struct ircd::log::debug
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
debug(const log &, const string_view &, ...)
|
2018-03-24 22:51:10 +01:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
debug(const string_view &, ...)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2018-01-21 10:17:33 +01:00
|
|
|
};
|
2018-04-23 23:17:38 +02:00
|
|
|
#endif
|
2016-08-26 06:38:15 +02:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 6
|
|
|
|
struct ircd::log::dwarning
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-01-21 10:17:33 +01:00
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
dwarning(const log &log, const string_view &fmt, args&&... a)
|
2018-01-21 10:17:33 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(log, facility::DWARNING, fmt, va_rtti{std::forward<args>(a)...});
|
2018-01-21 10:17:33 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
dwarning(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(general, facility::DWARNING, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-01-21 10:17:33 +01:00
|
|
|
};
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
struct ircd::log::dwarning
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
dwarning(const log &, const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
dwarning(const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 5
|
|
|
|
struct ircd::log::derror
|
2017-03-18 04:24:25 +01:00
|
|
|
{
|
2018-01-21 10:17:33 +01:00
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
derror(const log &log, const string_view &fmt, args&&... a)
|
2018-01-21 10:17:33 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(log, facility::DERROR, fmt, va_rtti{std::forward<args>(a)...});
|
2018-01-21 10:17:33 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
derror(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(general, facility::DERROR, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-01-21 10:17:33 +01:00
|
|
|
};
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
struct ircd::log::derror
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
derror(const log &, const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
derror(const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 4
|
|
|
|
struct ircd::log::info
|
2018-03-15 20:20:21 +01:00
|
|
|
{
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
info(const log &log, const string_view &fmt, args&&... a)
|
2018-03-15 20:20:21 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(log, facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
|
2018-03-15 20:20:21 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
info(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(general, facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-04-23 23:17:38 +02:00
|
|
|
};
|
|
|
|
#else
|
2018-05-22 01:55:10 +02:00
|
|
|
struct ircd::log::info
|
2018-04-23 23:17:38 +02:00
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
info(const log &, const string_view &, ...)
|
2018-03-24 22:51:10 +01:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
info(const string_view &, ...)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2018-03-15 20:20:21 +01:00
|
|
|
};
|
2018-04-23 23:17:38 +02:00
|
|
|
#endif
|
2018-03-15 20:20:21 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 3
|
|
|
|
struct ircd::log::notice
|
2017-03-18 04:24:25 +01:00
|
|
|
{
|
2018-01-21 10:17:33 +01:00
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
notice(const log &log, const string_view &fmt, args&&... a)
|
2018-01-21 10:17:33 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(log, facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
|
2018-01-21 10:17:33 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
notice(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(general, facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-01-21 10:17:33 +01:00
|
|
|
};
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
struct ircd::log::notice
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
notice(const log &, const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2016-08-26 06:38:15 +02:00
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
notice(const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if RB_LOG_LEVEL >= 2
|
|
|
|
struct ircd::log::warning
|
2018-03-15 20:20:21 +01:00
|
|
|
{
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
warning(const log &log, const string_view &fmt, args&&... a)
|
2018-03-15 20:20:21 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(log, facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
|
2018-03-15 20:20:21 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
warning(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
vlog(general, facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-04-23 23:17:38 +02:00
|
|
|
};
|
|
|
|
#else
|
2018-05-22 01:55:10 +02:00
|
|
|
struct ircd::log::warning
|
2018-04-23 23:17:38 +02:00
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
warning(const log &, const string_view &, ...)
|
2018-03-24 22:51:10 +01:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
warning(const string_view &, ...)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
2018-03-15 20:20:21 +01:00
|
|
|
};
|
2018-04-23 23:17:38 +02:00
|
|
|
#endif
|
2018-03-15 20:20:21 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 1
|
2018-01-21 10:17:33 +01:00
|
|
|
struct ircd::log::error
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-01-21 10:17:33 +01:00
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
error(const log &log, const string_view &fmt, args&&... a)
|
2018-01-21 10:17:33 +01:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(log, facility::ERROR, fmt, va_rtti{std::forward<args>(a)...});
|
2018-01-21 10:17:33 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
error(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(general, facility::ERROR, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-01-21 10:17:33 +01:00
|
|
|
};
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
struct ircd::log::error
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
error(const log &, const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
error(const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 0
|
2018-01-21 10:17:33 +01:00
|
|
|
struct ircd::log::critical
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-01-21 10:17:33 +01:00
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
critical(const log &log, const string_view &fmt, args&&... a)
|
2018-01-21 10:17:33 +01:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(log, facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...});
|
2018-01-21 10:17:33 +01:00
|
|
|
}
|
2018-04-23 23:23:29 +02:00
|
|
|
|
|
|
|
template<class... args>
|
2018-12-10 22:00:33 +01:00
|
|
|
critical(const string_view &fmt, args&&... a)
|
2018-04-23 23:23:29 +02:00
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(general, facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...});
|
2018-04-23 23:23:29 +02:00
|
|
|
}
|
2018-01-21 10:17:33 +01:00
|
|
|
};
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
struct ircd::log::critical
|
|
|
|
{
|
2018-12-10 22:00:33 +01:00
|
|
|
critical(const log &, const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
|
2018-12-10 22:00:33 +01:00
|
|
|
critical(const string_view &, ...)
|
2018-05-22 01:55:10 +02:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 7
|
2017-03-18 04:24:25 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::debug(const string_view &fmt,
|
2017-03-18 04:24:25 +01:00
|
|
|
args&&... a)
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2017-03-18 04:24:25 +01:00
|
|
|
operator()(facility::DEBUG, fmt, va_rtti{std::forward<args>(a)...});
|
2016-08-26 06:38:15 +02:00
|
|
|
}
|
2018-03-24 22:51:10 +01:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::debug(const string_view &fmt,
|
2018-03-24 22:51:10 +01:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 6
|
2017-03-18 04:24:25 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::dwarning(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
args&&... a)
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
operator()(facility::DWARNING, fmt, va_rtti{std::forward<args>(a)...});
|
2016-08-26 06:38:15 +02:00
|
|
|
}
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::dwarning(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 5
|
2017-03-18 04:24:25 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::derror(const string_view &fmt,
|
2017-03-18 04:24:25 +01:00
|
|
|
args&&... a)
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
operator()(facility::DERROR, fmt, va_rtti{std::forward<args>(a)...});
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::derror(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
2016-08-26 06:38:15 +02:00
|
|
|
}
|
2018-05-22 01:55:10 +02:00
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 4
|
2018-03-15 20:20:21 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::info(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
args&&... a)
|
2018-03-15 20:20:21 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
operator()(facility::INFO, fmt, va_rtti{std::forward<args>(a)...});
|
2018-03-15 20:20:21 +01:00
|
|
|
}
|
2018-03-24 22:51:10 +01:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::info(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
2018-03-24 22:51:10 +01:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2018-03-15 20:20:21 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 3
|
2017-03-18 04:24:25 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::notice(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
args&&... a)
|
2016-08-26 06:38:15 +02:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
operator()(facility::NOTICE, fmt, va_rtti{std::forward<args>(a)...});
|
2016-08-26 06:38:15 +02:00
|
|
|
}
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::notice(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 2
|
2018-03-15 20:20:21 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::warning(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
args&&... a)
|
2018-03-15 20:20:21 +01:00
|
|
|
{
|
2018-05-22 01:55:10 +02:00
|
|
|
operator()(facility::WARNING, fmt, va_rtti{std::forward<args>(a)...});
|
2018-03-15 20:20:21 +01:00
|
|
|
}
|
2018-03-24 22:51:10 +01:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::warning(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
2018-03-24 22:51:10 +01:00
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2018-03-15 20:20:21 +01:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 1
|
2017-03-18 04:24:25 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::error(const string_view &fmt,
|
2017-03-18 04:24:25 +01:00
|
|
|
args&&... a)
|
2007-01-25 07:40:21 +01:00
|
|
|
{
|
2017-03-18 04:24:25 +01:00
|
|
|
operator()(facility::ERROR, fmt, va_rtti{std::forward<args>(a)...});
|
2016-08-26 06:38:15 +02:00
|
|
|
}
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::error(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2016-06-23 03:23:24 +02:00
|
|
|
|
2018-05-22 01:55:10 +02:00
|
|
|
#if RB_LOG_LEVEL >= 0
|
2017-03-18 04:24:25 +01:00
|
|
|
template<class... args>
|
|
|
|
void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::critical(const string_view &fmt,
|
2017-03-18 04:24:25 +01:00
|
|
|
args&&... a)
|
|
|
|
{
|
|
|
|
operator()(facility::CRITICAL, fmt, va_rtti{std::forward<args>(a)...});
|
|
|
|
}
|
2018-05-22 01:55:10 +02:00
|
|
|
#else
|
|
|
|
inline void
|
2018-12-10 22:00:33 +01:00
|
|
|
ircd::log::log::critical(const string_view &fmt,
|
2018-05-22 01:55:10 +02:00
|
|
|
...)
|
|
|
|
{
|
|
|
|
// Required in gcc 6.3.0 20170519, template param packs are not DCE'ed
|
|
|
|
}
|
|
|
|
#endif
|
2017-03-18 04:24:25 +01:00
|
|
|
|
|
|
|
template<class... args>
|
|
|
|
void
|
|
|
|
ircd::log::log::operator()(const facility &f,
|
2018-12-10 22:00:33 +01:00
|
|
|
const string_view &fmt,
|
2017-03-18 04:24:25 +01:00
|
|
|
args&&... a)
|
|
|
|
{
|
2018-04-24 00:46:09 +02:00
|
|
|
vlog(*this, f, fmt, va_rtti{std::forward<args>(a)...});
|
2017-03-18 04:24:25 +01:00
|
|
|
}
|