Solution to initgooglelogging failure after shutdowngooglelogging in glog

Source: Internet
Author: User

Note: The latest code has fixed this bughttps: // code.google.com/p/google-glog/issues/detail? Id = 142
Https://code.google.com/p/google-glog/source/browse/trunk/src/utilities.cc


The cause is very simple, utilities. shutdowngoogleloggingutilities in the CC file does not reset the Global static variable g_program_invocation_short_name to null. The following is the source code. The solution is to add g_program_invocation_short_name = NULL, because it is a static global variable, you cannot perform this operation in your own program unless you change it to a non-static global variable.
Source code file logging. CC1803 voidInitgooglelogging(Const char * argv0) {1804 glog_internal_namespace _: initgoogleloggingutilities (argv0); 1805} 1806 voidShutdowngooglelogging() {1808 glog_internal_namespace _: shutdowngoogleloggingutilities (); 1809 logdestination: deletelogdestinations (); 1810 Delete logging_directories_list; 1811 logging_directories_list = NULL; 1812}
Source code file src/utilities. CC57 static const char *G_program_invocation_short_name= NULL;
167 boolIsgooglelogginginitialized() {168 return g_program_invocation_short_name! = NULL, 169}
316 voidInitgoogleloggingutilities(Const char * argv0) {317 check (! Isgooglelogginginitialized () 318 <"You called initgooglelogging () twice! "; 319 const char * slash = strrchr (argv0, '/'); 320 # ifdef OS _windows321 if (! Slash) slash = strrchr (argv0, '\'); 322 # endif323 g_program_invocation_short_name = slash? Slash + 1: argv0; 324 g_main_thread_id = pthread_self (); 325 326 # ifdef have_stacktrace327 installfailurefunction (& dumpstacktraceandexit); 328 # endif329} 330 331 voidShutdowngoogleloggingutilities() {332 check (isgooglelogginginitialized () 333 <"You called shutdowngooglelogging () without calling initgooglelogging () first! "; 334 # ifdef have_syslog_h335 closelog (); 336 # endifG_program_invocation_short_name = NULL;337}

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.