glog - githeim/windheim_archive GitHub Wiki

glog

install

sudo apt-get install -y libgoogle-glog-dev

integrating glog into CMAKE project

find_package (glog  REQUIRED)
LINK_LIBRARIES(glog::glog)  or    target_link_libraries (myapp glog::glog)

example & run the example

#include <stdio.h>                                                      
#include "libmodule.h"                                                  
#include <glog/logging.h>                                               
                                                                        
int main(int argc, char *argv[]) {                                      
  // Initialize Google's logging library.                               
  google::InitGoogleLogging(argv[0]);                                   
  google::ParseCommandLineFlags(&argc, &argv, true);                    
  LOG(INFO) << "Chk " <<  " start";                                 
                                                                        
  printf("Project Log\n");                                      
                                                                        
  while (1) {                                                           
    printf("\033[1;33m[%s][%d] :x: chk \033[m\n",__FUNCTION__,__LINE__);
    LOG(INFO) << "Chk \033[1;32m"  <<  " Data  \033[m";                 
    sleep(1);                                                           
  }                                                                     
                                                                        
  return 0;                                                             
}                                                                       
                                                                        

run the program

./example --logtostderr=1

how to print out high precision number

double a = 3.141592653589793238;
LOG(INFO) << std::fixed << std::setprecision( 15 ) << a;
⚠️ **GitHub.com Fallback** ⚠️