程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> google-glog 開源庫分析(二):glog用法,google-glogglog

google-glog 開源庫分析(二):glog用法,google-glogglog

編輯:C++入門知識

google-glog 開源庫分析(二):glog用法,google-glogglog


glog使用

  • 設置符號變量,定制日志行為
    • 具體符號變量的設置看glog介紹中的符號變量
  • 日志系統初始化
    • 初始化函數:google::InitGoogleLogging(argv[0])
    • 初始化參數一般是第一個命令行參數--即程序的名稱
  • 結束時可以調用關閉日志系統函數
    • 關閉日志庫函數:google::ShutdownGoogleLogging()
  • 程序運行時,可通過命令行參數或環境變量來控制程序的日志行為

glog APIs:

  • void google::InitGoogleLogging(const char* argv0)
    • 初始化glog庫,參數是第一個命令行參數即程序名
  • void google::ShutdownGoogleLogging()
    • 關閉glog庫
  • void google::FlushLogFiles(LoSeverity min_severity)
    • [Thread-safe]指定級別以上的所有日志消息都立即寫入到日志文件中
  • void google::FlushLogFilesUnsafe(LogSeverity min_severity)
    • 非線程安全的輸出指定級別以上的日志消息,用於災難性程序問題時輸出必要的日志消息
  • void google::SetLogDestination(LogSeverity severity,const char* basefilename)
    • [Thread-safe]設置指定級別的日志輸出的日志文件,如果basefilename為""則表示該級別日志不輸出
  • void google::SetLogSymlink(LogSeverity severity,const char* symlinkbasename)
    • [Thread-safe]設置置頂級別的日志文件的軟連接,symlikbasename為空表示不設置軟連接
    • 如果不調用該函數,系統默認連接名稱是程序名
  • void google::AddLogSink(LogSink *destination)
  • void google::RemoveLogSink(LogSink *destination)
    • [Thread-safe]添加和刪除日志輸出渠道
  • void google::SetLogFilenameExtension(const char* filename_extension)
    • [Thread-safe]為所有日志文件添加文件擴展名,特別用於SetLogDestination()設置的日志文件
    • 通常做法是將監聽的端口號作為日志文件擴展名
  • void google::SetStderrLogging(LogSeverity min_severity)
    • [Thread-safe]確定除了輸出到日志文件同時還輸出到STDERR的日志最小級別
  • void google::LogToStderr()
    • [Thread-safe]設置只只將日志輸出到STDERR而不輸出到日志文件
  • void google::SetEmailLogging(LogSeverity min_severity,const char* address)
    • [Thread-safe]設置發送郵件的日志最小級別
  • bool google::SendEmail(const char *dest,const char *subject,const char *body)
    • [Thread-safe]發送郵件
  • const std::vector& google::GetLoggingDirectories()
    • 獲取日志輸出目錄集合
  • void google::InstallFailureSignalHandler()
    • 信號處理函數,處理的主要信號有SIGSEGV/SIGILL/SIGFPE/SIGBRT/SIGBUS/SIGTERM
  • void google::InstallFailureWriter(void (*writer)(const char *data,int size))
    • 設置系統崩潰時的輸出函數,data數據不一定是以'\0'結尾
  • void google::InstallFailureFunction(void (*fail_func)())
    • 設置LOG(FATAL)在輸出日志消息後調用的函數

google glog可以支持java

發發發阿發發發
 

Oasis 樂隊的《Supersonic》 的中文歌詞

Supersonic 中文歌詞
Wikipedia,自由的百科全書
收錄專輯:Definitely Maybe

Supersonic 超音速

I need to be myself
我要做自己
I can't be no one else
我不要像其他人一樣
I'm feeling supersonic
我正享受著超音速
Give me gin and tonic
請給我一杯gin and tonic
You can have it all but how much do you want it?
你可以一飲而盡但要喝多少杯才夠

You make me laugh
你讓我大笑
Give me your autograph
請給我你的簽名
Can I ride with you in your BMW ?
我可以坐上你的BMW一起兜風嗎?
You can sail with me in my yellow submarine
還是你可以坐上我的黃色潛水艇一同共游 (注1)

You need to find out
你得好好思索
'Cos no one's gonna tell you what I'm on about
因為不會有人告訴你我所言為何
You need to find a way for what you want to say
你得想辦法讓自己暢其所言
But before tomorrow
但得在天亮之前

'Cos my friend said he'd take you home
因為我的朋友說他會帶你回家
He sits in a corner all alone
他坐在角落獨自一個人
He lives under a waterfall
他住在瀑布底下
No body can see him
別人見不到他
No body can ever hear him call
也聽不到他的呼喚

You need to be yourself
你得做你自己
You can't be no one else
不要像其他人一樣
I know a girl called Elsa
我認識個叫做Elsa的女孩
She's into Alka Seltzer
她對Alka Seltzer很著迷(注2)
She sniffs it through a cane on a supersonic train
她在超音速火車裡用根管子吸食它

She made me laugh
她曾讓我大笑
I got her autograph
我也拿過她的簽名
She done it with a doctor on a helicopter
她曾在直升機裡和一位醫生搞過
She's sniffin in her tissue
而如今她卻拿衛生紙直打噴嚏
Sellin' the Big Issue
在大街上叫賣雜志 (注3)

And She finds out
而現在她終於了解
no one's gonna tell her what I'm on about
沒有人要告訴她我所言為何
You need to find a way for what she wants to say
你得想辦法聽懂她要講什麼
But ......余下全文>>
 

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved