glog摘记
projcet url:https://code.google.com/p/google-glog/
usage: application-level logging
setting flags
GLOG_logtostderr: If gflags not installed, you can useGLOG_logtostderr=1 ./your_application
stderrthreshold: Copy log messages at or above this level to stderr in addition to logfiles.
log_dir: If specified, logfiles are written into this directory instead of the default logging directory.
Conditional / Occasional Logging
LOG_IF(INFO, num_cookies > 10):
LOG_EVERY_N(INFO, 10): log messages on the 1st, 11th, 21st, ... times it is executed.
LOG_IF_EVERY_N(INFO, (size > 1024), 10): you can also limit the output to the first n occurrences.
LOG_FIRST_N(INFO, 20): you can also limit the output to the first n occurrences.
Debug Mode Support
Just need to add "D" before LOG, then these LOG will be compiled away to nothing for non-debug mode compiles.
CHECK Macros
CHECK()
CHECK_NE()
CHECK_EQ()
CHECK_NOTNULL()
If you are comparing C strings (char *), a handy set of macros performs case sensitive as well as case insensitive comparisons - CHECK_STREQ, CHECK_STRNE, CHECK_STRCASEEQ, and CHECK_STRCASENE. The CASE versions are case-insensitive.
You can safely pass NULL pointers for this macro. They treat NULL and any non-NULL string as not equal. Two NULLs are equal.
If you are comparing C strings (char *), a handy set of macros performs case sensitive as well as case insensitive comparisons - CHECK_STREQ, CHECK_STRNE, CHECK_STRCASEEQ, and CHECK_STRCASENE. The CASE versions are case-insensitive.
You can safely pass NULL pointers for this macro. They treat NULL and any non-NULL string as not equal. Two NULLs are equal.
Verbose Logging
VLOG(1) << "I'm printed when you run the program with --v=1 or higher";
VLOG(2) << "I'm printed when you run the program with --v=2 or higher";
Verbose logging can be controlled from the command line on a per-module basis:
--vmodule=mapreduce=2,file=1,gfs*=3 --v=0
will:
a. Print VLOG(2) and lower messages from mapreduce.{h,cc}
b. Print VLOG(1) and lower messages from file.{h,cc}
c. Print VLOG(3) and lower messages from files prefixed with "gfs"
d. Print VLOG(0) and lower messages from elsewhere
Failure Signal Handler
The signal handler can be installed by google::InstallFailureSignalHandler().
By default, the signal handler writes the failure dump to the standard error. You can customize the destination by InstallFailureWriter().
User-defined Failure Function
FATAL severity level messages or unsatisfied CHECK condition terminate your program. You can change the behavior of the termination by InstallFailureFunction.
void YourFailureFunction() {
// Reports something...
exit(1);
}
int main(int argc, char* argv[]) {
google::InstallFailureFunction(&YourFailureFunction);
}
By default, glog tries to dump stacktrace and makes the program exit with status 1. The stacktrace is produced only when you run the program on an architecture for which glog supports stack tracing (as of September 2008, glog
supports stack tracing for x86 and x86_64).
Raw Logging
The header file <glog/raw_logging.h> can be used forthread-safe logging, which does not allocate any memory or acquire any locks.
Therefore, the macros defined in this header file can be used by low-level memory allocation and synchronization code. Please check src/glog/raw_logging.h.in for detail.
glog摘记的更多相关文章
- window环境下glog的安装
window环境下glog的安装 分类: c++2014-09-23 14:12 32人阅读 评论(0) 收藏 举报 下载后解压,利用Visual Studio打开google-glog.sln.生成 ...
- Google glog 使用
Google glog 使用 1 简介 Googleglog 库实现了应用级的日志记录,提供了C++ 风格的流操作和各种助手宏. 代码示例: #include <glog/logg ...
- glog使用
How To Use Google Logging Library Glog 的基本使用方法在google code上有介绍:How To Use Google Logging Library ;最好 ...
- 谷歌日志库GLog 使用说明
1 引用头文件 加载库 #include <glog/include/logging.h> #pragma comment(lib,"libglog.lib") 2 初 ...
- Glog
Glog的简单入门,glog虽然在配置参数方面比较麻烦,但是在小规模程序中,由于其简单灵活,也许会有优势. 0, glog 是google的开源日志系统,相比较log4系列的日志系统,它更加轻巧灵活 ...
- glog另启动线程写文本日志
glog本身是很高效的,google的大牛肯定知道大规模的写日志用glog的话肯定会影响业务线程的处理,带负荷的磁盘IO谁都桑不起.比方levelDB就是默认异步写,更不用说google的三驾马车都是 ...
- glog 使用
glog 使用 来源:http://www.cnblogs.com/tianyajuanke/archive/2013/02/22/2921850.html 一.安装配置 1.简介 google 出的 ...
- Glog 和 Log4cxx 的对比
转自:http://monkeycn.iteye.com/blog/1021703 #1 Log4cxx有比较完整的配置文档方式,xml和java配置档:GLog只能通过启动程序的时候的输入参数来配置 ...
- GLOG使用Demo
GLOG使用Demo GLOG是Google开源的一个精简的日志系统,博主简单学习了一下并记录常见用法,以备日常查询 一.安装 照例是编译安装,不过没有使用cmake git clone https: ...
随机推荐
- Poj2948Martian Mining(记忆化)
链接 这题意好难懂 看得迷迷糊糊 想的也迷迷糊糊 后来睡了会突然想到了..不就是类似以前的矩阵操作 从右下角记忆化 大的由小的推来 dp[i][j] = max(dp[i-1][j]+s1,dp ...
- poj2192
初看这道题,以为是先用SA和SC求LCS,再从SC中把SA剔除,看剩下来的是不是SB(……) 显然不对;因为SC与SA的公共子串不止一种,判断不一定正确. 于是考虑SC中每一个字符,如果能够匹配,那么 ...
- BZOJ3232: 圈地游戏
题解: 神题一道... 题解戳这里:http://hi.baidu.com/strongoier/item/0425f0e5814e010265db0095 分数规划可以看这里:http://blog ...
- Java [Leetcode 242]Valid Anagram
题目描述: Given two strings s and t, write a function to determine if t is an anagram of s. For example, ...
- android广告平台介绍
广告模式: 广告条:最普遍的广告模式,嵌入在应用界面内,用户点击行为会带来收入. 积分墙:应用通过限制功能.去广告等引导用户进入积分墙页面下载广告应用得到积分来换取使用的模式,用户安装完推荐广 ...
- POJ 2435Navigating the City(bfs)
题意:给你一个地图,’+’代表十字路口,‘-’‘|’表示街道,‘.’表示建筑物,‘s’,’E’ 起点和终点.输出从起点到终点的的 最短路径(包括方向和沿该方向的经过的十字路口数) 分析:ans[i][ ...
- Kafka Unknow host
今天在测试kafka时遇到 Unknow host问题,经过Google,找到了解决办法,总结如下: 原因:Linux主机名称为null 第一步通过修改/etc/sysconfig/network 中 ...
- MFC 文件操作
MFC中文件的建立 在操作系统中,文件是放在一定的目录下,在创建以及操作文件以前,我们要查看文件要保存的目录有没有存在,如果不存在要创建.这就要用到GetFileAttributes()和Create ...
- ubuntu 常用软件配置
1. 首先重装系统后需要执行: sudo apt-get install update 2. 然后安装必要的软件: terminator, vim, git,
- java继承和多态
父类和子类 如果类C1扩展自另一个类C2,那么C1称为子类或派生类,C2称为父类或基类.派生类可以从它的基类中继承可访问的数据域和方法,还可添加新数据域和新方法 例如:实现一个几何图形基类; clas ...