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摘记的更多相关文章

  1. window环境下glog的安装

    window环境下glog的安装 分类: c++2014-09-23 14:12 32人阅读 评论(0) 收藏 举报 下载后解压,利用Visual Studio打开google-glog.sln.生成 ...

  2. Google glog 使用

    Google glog 使用 1        简介 Googleglog 库实现了应用级的日志记录,提供了C++ 风格的流操作和各种助手宏. 代码示例: #include <glog/logg ...

  3. glog使用

    How To Use Google Logging Library Glog 的基本使用方法在google code上有介绍:How To Use Google Logging Library ;最好 ...

  4. 谷歌日志库GLog 使用说明

    1 引用头文件 加载库 #include <glog/include/logging.h> #pragma comment(lib,"libglog.lib") 2 初 ...

  5. Glog

    Glog的简单入门,glog虽然在配置参数方面比较麻烦,但是在小规模程序中,由于其简单灵活,也许会有优势. 0,  glog 是google的开源日志系统,相比较log4系列的日志系统,它更加轻巧灵活 ...

  6. glog另启动线程写文本日志

    glog本身是很高效的,google的大牛肯定知道大规模的写日志用glog的话肯定会影响业务线程的处理,带负荷的磁盘IO谁都桑不起.比方levelDB就是默认异步写,更不用说google的三驾马车都是 ...

  7. glog 使用

    glog 使用 来源:http://www.cnblogs.com/tianyajuanke/archive/2013/02/22/2921850.html 一.安装配置 1.简介 google 出的 ...

  8. Glog 和 Log4cxx 的对比

    转自:http://monkeycn.iteye.com/blog/1021703 #1 Log4cxx有比较完整的配置文档方式,xml和java配置档:GLog只能通过启动程序的时候的输入参数来配置 ...

  9. GLOG使用Demo

    GLOG使用Demo GLOG是Google开源的一个精简的日志系统,博主简单学习了一下并记录常见用法,以备日常查询 一.安装 照例是编译安装,不过没有使用cmake git clone https: ...

随机推荐

  1. UVa 1639 (期望) Candy

    题意: 两个盒子里各有n颗糖,每天有p的概率从第一个盒子里取一颗糖,1-p的概率从第二个盒子里去一颗糖.直到某一天打开某个盒子忽然发现没糖了,求另一个盒子里剩余糖果数的期望. 分析: 紫书上面已经分析 ...

  2. [POJ 2588] Snakes

    同swustoj 8 Snakes Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 1015   Accepted: 341 ...

  3. Vs 引用第三方DLL文件 版本不一致问题 (npoi与memcached中的ICSharpCode.SharpZipLib版本冲突的解决方案)

    最近在 做 MailChimp 与网站功能 集成时,发现 MailChimp 2API 中的 MailChimp.dll  中的依赖项 SerivceStack.Text.dll (版本为3.9.71 ...

  4. fingerprintjs

    Valve/fingerprintjs FingerprintJS - 在浏览器端实现指纹识别

  5. RMAN备份与恢复深入解<一>

    一 数据库版本 SQL> select *from v$version; BANNER ----------------------------------------------------- ...

  6. 表格的一些原生js操作(隔行变色,高亮显示,添加删除,搜索)

    看着网上的视频教程,虽说还是有点简单,但还是不免想记录下.这些操作包括(隔行变色,高亮显示,添加删除,搜索功能),而这儿就是涉及table的原有属性“tBodies” “rows” “cells”等几 ...

  7. u-boot向linux内核传递启动参数(详细)

    U-BOOT 在启动内核时,会向内核传递一些参数.BootLoader 可以通过两种方法传递参数给内核,一种是旧的参数结构方式(parameter_struct),主要是 2.6 之前的内核使用的方式 ...

  8. 转换Json格式帮助类

    using System; using System.Collections.Generic; using System.Text; using System.Reflection; using Sy ...

  9. centos vpn client set

    http://my.oschina.net/fishman/blog/96227 先检查服务器是否安装过 ppp, pptp, pptp-setup, 如果没有, yum -y install  安装 ...

  10. vim讲解

    文本编辑vi使用 最好使用vim,采用sudo apt-get install vim vi是Linux及类Unix系统中主流的命令行文本编辑器,功能极为强大,vim是增强版本的vim.Vim的高级地 ...