Skip to content
C++ implementation of the Google logging module
C++ CMake M4 C Shell Makefile Python
Branch: master
Clone or download
Pull request Compare This branch is 4 commits ahead, 46 commits behind google:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.bazelci
bazel
cmake
doc
example
m4
packages
src
toolchains
.gitignore
.travis.ubuntu.sh
.travis.yml
AUTHORS
BUILD
CMakeLists.txt
CONTRIBUTING.md
CONTRIBUTORS
COPYING
ChangeLog
Dockerfile.ubuntu.template
INSTALL
Makefile.am
README.md
README.windows
WORKSPACE
appveyor.yml
autogen.sh
configure.ac
glog-config.cmake.in
libglog.pc.in

README.md

Build Status Grunt status

This repository contains a C++ implementation of the Google logging module. Documentation for the implementation is in doc/.

See INSTALL for (generic) installation instructions for C++: basically

./autogen.sh && ./configure && make && make install

Build

  1. Build VS project with CMake
    • Check BUILD_SHARED_LIBS
    • Uncheck WITH_GFLASS
    • CMAKE_INSTALL_PREFIX fill in the install path
    • Configure
    • Generate
  2. Compile and install using VS
    • Debug: Generate INSTALL project
    • Release: Generate INSTALL project
Some dependent libraries that glog projects may need
kernel32.lib
user32.lib
gdi32.lib
winspool.lib
shell32.lib
ole32.lib
oleaut32.lib
uuid.lib
comdlg32.lib
advapi32.lib

Usage

  1. To add glog's DLL header to your include path
  2. To add glog's DLL import library to your project
  3. To add GLOG_NO_ABBREVIATED_SEVERITIES to Preprocessor Definitions
  4. Additional Dependencies add
    • Debug:glogd.lib
    • Release:glog.lib
  5. To copy the DLL in a post-build event
    • Debug:xcopy /y /d "..\path_to_install\bin\glogd.dll" "$(OutDir)"
    • Release:xcopy /y /d "..\path_to_install\bin\glog.dll" "$(OutDir)"

Example

#include <glog/logging.h>
int main()
{
    FLAGS_log_dir = "/home/$USER";              // Make sure the folder exists
    google::InitGoogleLogging("");
    google::SetLogDestination(google::GLOG_INFO, "/home/$USER/INFO"); // Make sure the folder exists
    google::SetStderrLogging(google::GLOG_INFO);
    google::SetLogFilenameExtension("log_");
    FLAGS_colorlogtostderr = true;              // Set log color
    FLAGS_logbufsecs = 0;                       // Set log output speed(s)
    FLAGS_max_log_size = 1024;                  // Set max log file size
    FLAGS_stop_logging_if_full_disk = true;     // If disk is full

    LOG(INFO) << "[" << "fileName" << " " << "functionName" << "] " << "logContent";
    LOG(WARNING) << "[" << "fileName" << " " << "functionName" << "] " << "logContent";
    LOG(ERROR) << "[" << "fileName" << " " << "functionName" << "] " << "logContent";

    google::ShutdownGoogleLogging();
    return 0;
}
You can’t perform that action at this time.