GLOG is the Google logging facility, which allows a C++ program, as it
executes, to record incidents of INFO, WARNING, ERROR, or FATAL
type, and to write corresponding messages to files. The user can
control various aspects of the logging procedure, including limiting
the total number of messages, or only printing messages during DEBUG
runs, and so on. GLOG also provicdes a "check" feature, similar to
the assert statement in C, which terminates execution if
a given condition is not satisfied.
On any ARC cluster, check the installation details
by typing "module spider glog".
GLOG requires that a module be loaded before it can be run.
One version of the appropriate commands for use on NewRiver is:
module purge module load glog/0.3.3
In the following batch file, a user program estimates the derivative
of the logarithm function using finite differences. The program
uses GLOG to warn if certain conditions occur, and to terminate if
a division by zero is attempted. By using the switch
export GLOG_logtostderr=1 ./glog_test
the user guarantees that the logging information will appear on stderr
rather than in files in the /tmp directory.
#! /bin/bash # #PBS -l walltime=00:05:00 #PBS -l nodes=1:ppn=1 #PBS -W group_list=newriver #PBS -q open_q #PBS -j oe cd $PBS_O_WORKDIR module purge module load glog/0.3.3 # g++ -c -I$GLOG_INC glog_test.cpp g++ glog_test.o -o glog_test -L$GLOG_LIB -lglog # # Without this switch, INFO and WARNING messages only go to files # called /tmp/[PROGRAM_NAME].INFO, /tmp/[PROGRAM_NAME].WARNING. # This way, all messages appear on stderr. # export GLOG_logtostderr=1 ./glog_test
A complete set of files to carry out a similar process are available in