Google-glog open-source database analysis (2): glog usage

Source: Internet
Author: User

Glog usage
    • Set symbol variables to customize log Behavior
      • For more information about how to set symbol variables, see symbol variables in glog introduction.
    • Log system initialization
      • Initialization function: Google: initgooglelogging (argv [0])
      • The initialization parameter is generally the first command line parameter-that is, the program name.
    • You can call the function to disable the log system at the end.
      • Function for disabling logstore: Google: shutdowngooglelogging ()
    • When the program is running, you can use command line parameters or environment variables to control the log behavior of the program.
Glog APIs:
  • Void Google: initgooglelogging (const char * argv0)
    • Initialize the glog library. The parameter is the first command line parameter, that is, the program name.
  • Void Google: shutdowngooglelogging ()
    • Disable glog Library
  • Void Google: flushlogfiles (loseverity min_severity)
    • [Thread-safe] All log messages of a specified level or above are immediately written to the log file.
  • Void Google: flushlogfilesunsafe (logseverity min_severity)
    • Non-thread-Safe Output of log messages of a specified level or above, used to output necessary log messages in case of catastrophic program Problems
  • Void Google: setlogdestination (logseverity severity, const char * baseFilename)
    • [Thread-safe] sets the log file output at the specified level. If basefilename is "", logs of this level are not output.
  • Void Google: setlogsymlink (logseverity severity, const char * symlinkBasename)
    • [Thread-safe] sets the soft connection of top-level log files. If symlikbasename is null, it indicates no soft connection is set.
    • If you do not call this function, the default connection name is the program name.
  • Void Google: addlogsink (logsink * destination)
  • Void Google: removelogsink (logsink * destination)
    • [Thread-safe] adding and deleting log output channels
  • Void Google: setlogfilenameextension (const char * filename_extension)
    • [Thread-safe] adds a file extension for all log files, especially for log files set by setlogdestination ()
    • The common practice is to use the listening port number as the log file extension.
  • Void Google: setstderrlogging (logseverity min_severity)
    • [Thread-safe] determines the minimum log level that is output to stderr in addition to the log file
  • Void Google: logtostderr ()
    • [Thread-safe] setting only outputs logs to stderr but not to log files
  • Void Google: setemaillogging (logseverity min_severity, const char * address)
    • [Thread-safe] sets the minimum log level for sending mail
  • Bool Google: sendemail (const char * DEST, const char * subject, const char * Body)
    • [Thread-safe] Send email
  • Const STD: Vector & Google: getloggingdirectories ()
    • Get log output directory set
  • Void Google: installfailuresignalhandler ()
    • Signal processing function. The main signal processed is SIGSEGV/sigill/sigfpe/sigbrt/sigbus/sigterm.
  • Void Google: installfailurewriter (void (* writer) (const char * data, int size ))
    • Set the output function when the system crashes. The data does not necessarily end with '\ 0'.
  • void Google: installfailurefunction (void (* fail_func )())
    • set the function called by log (fatal) after the log message is output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.