0

I write logging results of working on a data file with my program in a file, which also contains the name of the data file in the log file name, and for reproducibility the data file content is also logged. If the data file is correct, it works OK. If the data file is bad, then the further work is refused; it works fine. In my GUI environment, the user might have a second attempt, and second time provides a correct data file, under a different name. However, the second reading aborts the program, because in the block

  google::SetLogDestination(0, LogFileName.c_str() );
  google::InitGoogleLogging(FileName);

the initialization command occurs second time. How can I restart, terminate, reinitalize, close, or whatever called, the logging?

katang
  • 2,474
  • 5
  • 24
  • 48

1 Answers1

1

Normally, the logging is for the whole program. So, it might log hundreds of interactions with the users (some of which are refused/don't work/etc). You should move these commands to a place where they get invoked once at program startup. They should not be invoked on a per attempt/per user basis.

See docs : http://rpg.ifi.uzh.ch/docs/glog.html

There are no functions to restart, terminate, reinitalize, or close. You can flush to disk if you are having trouble with buffering, but it sounds like you just didn't understand how the library was intended to be used.

dolgom
  • 611
  • 1
  • 11
  • 27
LawfulEvil
  • 2,267
  • 24
  • 46
  • OK, I understand how it was intended to be used, and it is absolutely correct for CLI programs. I simply hoped that there is some way to use it for documenting elaboration of a file, rather than a session of series of files, and I should not exit/enter my GUI program to do so. – katang Mar 11 '16 at 17:12