资源简介
易用而又强大的C++跨平台日志库,可以输出日志到控制台窗口,文件,http服务器

代码片段和文件信息
#include “yaolog.h“
#include
#include
#include
#ifdef _YAO_LOG_WIN32_
#include
#include
#include
#include
#pragma comment(lib “Ws2_32.lib“)
#pragma comment(lib “shlwapi.lib“)
#pragma comment(lib “Rpcrt4.lib“)
#pragma warning(disable : 4996)
#else
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#endif
namespace YaoUtil {
// max size of ini file in bytes
const int MAX_INI_FILE_SIZE = 1024*32;
// default log buffer size in bytes
const size_t BUF_SIZE = 1024*4;
// max size of the queue for post
const size_t MAX_QUEUE_SIZE = 1000;
const int THREAD_CYCLE_SPAN_MILLISECOND = 2000;
const int THREAD_EXIT_TIMEOUT_MILLISECOND = 300;
char *g_pData = NULL;
char *g_pRealData = NULL;
bool g_bUseNewBuffer = false;
std::queue > g_textData;
std::queue > g_binData;
std::map g_files;
void ResetBuffer()
{
memset(g_pData 0 BUF_SIZE);
if (g_bUseNewBuffer)
{
delete [] g_pRealData;
g_bUseNewBuffer = false;
}
g_pRealData = NULL;
}
LOGOUT_FLAG ToFlag(const std::string& outFlag)
{
LOGOUT_FLAG flag_;
if (StrUtil::CompareNoCase(outFlag “file“)) flag_ = LOGOUT_FLAG_FILE;
else if (StrUtil::CompareNoCase(outFlag “stdout“)) flag_ = LOGOUT_FLAG_STDOUT;
else if (StrUtil::CompareNoCase(outFlag “remote“)) flag_ = LOGOUT_FLAG_REMOTE;
else flag_ = LOGOUT_FLAG_OUTPUTDEBUGSTRING;
return flag_;
}
void Queue2Vector(std::queue >& data_
std::vector > >& new_data)
{
std::string last_key;
std::vector new_value;
bool firstElement = true;
while (!data_.empty())
{
std::string& key_ = data_.front().first;
std::string& value_ = data_.front().second;
if (firstElement)
{
last_key = key_;
new_value.push_back(value_);
firstElement = false;
}
else
{
if (key_ != last_key)
{
new_data.push_back(make_pair(last_key new_value));
last_key = key_;
new_value.clear();
}
new_value.push_back(value_);
}
data_.pop();
}
if (!last_key.empty())
{
assert(new_value.size() > 0);
new_data.push_back(make_pair(last_key new_value));
}
}
TinyMutex::TinyMutex()
{
#ifdef _YAO_LOG_WIN32_
InitializeCriticalSection(&m_handle);
#else
pthread_mutex_init(
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 374 2013-01-24 15:33 test_linux\logconfig.ini
文件 2097 2013-01-24 15:41 test_linux\main.cpp
文件 419 2013-01-24 15:35 test_windows\logconfig.ini
文件 2164 2013-01-24 15:40 test_windows\main.cpp
文件 53767 2013-01-24 15:40 yaolog.cpp
文件 20476 2013-01-24 15:43 yaolog.h
相关资源
- 国际象棋的qt源代码
- C++中头文件与源文件的作用详解
- C++多线程网络编程Socket
- VC++ 多线程文件读写操作
- 利用C++哈希表的方法实现电话号码查
- 移木块游戏,可以自编自玩,vc6.0编写
- C++纯文字DOS超小RPG游戏
- VC++MFC小游戏实例教程(实例)+MFC类库
- 连铸温度场计算程序(C++)
- 6自由度机器人运动学正反解C++程序
- Em算法(使用C++编写)
- libstdc++-4.4.7-4.el6.i686.rpm
- VC++实现CMD命令执行与获得返回信息
- 白话C++(全)
- C++标准库第1、2
- 大数类c++大数类
- C++语言编写串口调试助手
- c++素数筛选法
- C++ mqtt 用法
- 商品库存管理系统 C++ MFC
- c++ 多功能计算器
- C++17 In Detail
- Qt5串口通信-windows
- 嵌入式QtC++编程课件
- 颜色识别形状识别STM103嵌入式代码
- 新编Windows API参考大全.doc
- windows hook 框架(detours )
- c++ 邮件多附件群发
- c++ 透明代理(hookproxy)
- mfc 调用redis
评论
共有 条评论