Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to use glog Log Library in Linux Environment

Shulou Source: shulou.com Published: 2022-06-01 23:03:09 10月03日 Update

How to use glog log library in Linux environment? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.

Generate linux library

Centos7.3 used in the Linux version, compiled to generate a library

1. Cd glog-0.3.3

2.. / configure

3. Make

After the completion of make, the corresponding library files will be generated under .lib.

Using glog Library under Linux

Linux uses static libraries to test. The header files of copy static libraries libglog.an and src/glog go to your project directory, create main.cpp files, and add the following code:

/ * Copyright (C), 2016-2018 FileName: mainDescription: Glog uses Demo***/#include # include "glog/logging.h" int main () {/ / initialization parameter FLAGS_logtostderr = FALSE / / TRUE: standard output, FALSE: file output FLAGS_alsologtostderr = TRUE; / / whether standard output FLAGS_colorlogtostderr = FALSE; / / standard output with color FLAGS_logbufsecs = 0 is required besides log files; / / set the maximum number of seconds that logs can be buffered, 0 means real-time output FLAGS_max_log_size = 10; / / log file size (in MB) FLAGS_stop_logging_if_full_disk = true / / whether disk google::InitGoogleLogging ("mqttserver") is recorded when the disk is full; google::SetLogDestination (google::GLOG_INFO, ". / test"); LOG (INFO)

Tags: Output files logs standards generation disk static help compilation environment maximum clear code content units parameters size real-time for this engineering Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia Huawei OPPO Reno Xiaomi Redmi