Example #1
0
void Slog::emerg(const char *format, ...)
{
	ThreadImpl *thread = getPriv();
	va_list args;

	if(!thread)
		return;

	va_start(args, format);
	overflow(EOF);
	emerg();
	vsnprintf(thread->_msgbuf, sizeof(thread->_msgbuf), format, args);
	thread->_msgpos = strlen(thread->_msgbuf);
	overflow(EOF);
	va_end(args);
}
Example #2
0
    static void log(const std::string &log_msg,
            int /*line*/,
            const char */*funcName*/,
            const char */*fileName*/,
            LogLevel level)
    {
        auto console = spdlog::get("console");
        auto syslog = spdlog::get("syslog");
        if (!console && !syslog)
        {
            std::cerr << "Logger not set-up yet ! Will display log message as is." << std::endl;
            std::cerr << log_msg << std::endl;
            return;
        }

        switch (level)
        {
            case LogLevel::DEBUG:
                if (console)
                    console->debug(log_msg);
                if (syslog)
                    syslog->debug(log_msg);
                break;
            case LogLevel::INFO:
                if (console)
                    console->info(log_msg);
                if (syslog)
                    syslog->info(log_msg);
                break;
            case LogLevel::NOTICE:
                if (console)
                    console->notice(log_msg);
                if (syslog)
                    syslog->notice(log_msg);
                break;
            case LogLevel::WARN:
                if (console)
                    console->warn(log_msg);
                if (syslog)
                    syslog->warn(log_msg);
                break;
            case LogLevel::ERROR:
                if (console)
                    console->error(log_msg);
                if (syslog)
                    syslog->error(log_msg);
                break;
            case LogLevel::CRIT:
                if (console)
                    console->critical(log_msg);
                if (syslog)
                    syslog->critical(log_msg);
                break;
            case LogLevel::ALERT:
                if (console)
                    console->alert(log_msg);
                if (syslog)
                    syslog->alert(log_msg);
                break;
            case LogLevel::EMERG:
                if (console)
                    console->emerg(log_msg);
                if (syslog)
                    syslog->emerg(log_msg);
                break;
        }
    }