Exemple #1
0
WBXML_DECLARE(void) wbxml_log_error(WB_UTINY type, const WB_TINY *fmt, ...)
{
    char buf[WBXML_LOG_FORMAT_SIZE];
    va_list args;
    
    format_log_message(buf, type, fmt);
    
    va_start(args, fmt);
    vfprintf(stderr, buf, args);   
    va_end(args);
}
Exemple #2
0
    int32_t FileLogDevice::write(const struct log_message_t& log_message) {
        if (get_loglevel() > log_message.loglevel) {
            return 0;
        }

        char buffer[1024] = {0};
        int32_t split_policy;
        int32_t nformated;

        nformated = format_log_message(buffer, 1022, log_message);
        split_policy = get_split_policy();

        {
            Guard<Mutex> guard(&_mutex);

            if (!is_opened()) {
                return -1;
            }

            if (BGCC_LOG_SPLIT_POLICY_BY_TIME == split_policy) {
                if (exec_time_split_policy() != 0) {
                    return -1;
                }
            } else {
                if (exec_size_split_policy(nformated) != 0) {
                    return -1;
                }
            }

            if (!is_opened()) {
                return -1;
            }

            fwrite(buffer, nformated, 1, _fp);
            _file_size += nformated;

            fflush(_fp);
        }

        return 0;
    }