Example #1
0
File: log.cpp Project: storborg/uhd
uhd::_log::log::~log(void)
{
    if (_log_it) {
        this->_log_info.message = _ss.str();
        log_rs().push(this->_log_info);
    }
}
Example #2
0
File: log.cpp Project: paneda/uhd
uhd::_log::log::~log(void)
{
    if (not _log_it)
        return;

    _ss << std::endl;
    try {
        log_rs().log_to_file(_ss.str());
    }
    catch(const std::exception &e) {
        /*!
         * Critical behavior below.
         * The following steps must happen in order to avoid a lock-up condition.
         * This is because the message facility will call into the logging facility.
         * Therefore we must disable the logger (level = never) before messaging.
         */
        log_rs().level = never;
        UHD_MSG(error)
                << "Logging failed: " << e.what() << std::endl
                << "Logging has been disabled for this process" << std::endl
                ;
    }
}
Example #3
0
File: log.cpp Project: storborg/uhd
/***********************************************************************
 * The logger object implementation
 **********************************************************************/
uhd::_log::log::log(
    const uhd::log::severity_level verbosity,
    const std::string &file,
    const unsigned int line,
    const std::string &component,
    const boost::thread::id thread_id
    ) :
    _log_it(verbosity >= log_rs().global_level)
{
    if (_log_it){
        this->_log_info = uhd::log::logging_info(
            pt::microsec_clock::local_time(),
            verbosity,
            file,
            line,
            component,
            thread_id);
        }
}
Example #4
0
File: log.cpp Project: paneda/uhd
uhd::_log::log::log(
    const verbosity_t verbosity,
    const std::string &file,
    const unsigned int line,
    const std::string &function
)
{
    _log_it = (verbosity >= log_rs().level);
    if (_log_it)
    {
        const std::string time = pt::to_simple_string(pt::microsec_clock::local_time());
        const std::string header1 = str(boost::format("-- %s - level %d") % time % int(verbosity));
        const std::string header2 = str(boost::format("-- %s") % function).substr(0, 80);
        const std::string header3 = str(boost::format("-- %s:%u") % get_rel_file_path(file) % line);
        const std::string border = std::string(std::max(std::max(header1.size(), header2.size()), header3.size()), '-');
        _ss << std::endl
            << border << std::endl
            << header1 << std::endl
            << header2 << std::endl
            << header3 << std::endl
            << border << std::endl
            ;
    }
}
Example #5
0
File: log.cpp Project: storborg/uhd
void
uhd::log::set_logger_level(const std::string &key, uhd::log::severity_level level){
    log_rs().logger_level[key] = level;
}
Example #6
0
File: log.cpp Project: storborg/uhd
void
uhd::log::set_log_level(uhd::log::severity_level level){
    log_rs().global_level = level;
}
Example #7
0
File: log.cpp Project: storborg/uhd
/***********************************************************************
 * Public API calls
 **********************************************************************/
void
uhd::log::add_logger(const std::string &key, log_fn_t logger_fn)
{
    log_rs().add_logger(key, logger_fn);
}
Example #8
0
File: log.cpp Project: storborg/uhd
void uhd::_log::log_fastpath(const std::string &msg)
{
#ifndef UHD_LOG_FASTPATH_DISABLE
    log_rs().push_fastpath(msg);
#endif
}