Bitcoin Forum
January 22, 2018, 12:01:04 AM *
News: Electrum users must upgrade to 3.0.5 if they haven't already. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [PULL] Improve debug logging  (Read 982 times)
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1512


View Profile
March 03, 2011, 01:58:58 AM
#1


URL: https://github.com/bitcoin/bitcoin/pull/90

This change does two things:

  • Timestamp each line in debug log, for easier problem tracking.
  • Close and re-open debug log every 2000 lines, to enable log rotation software to replace the log while bitcoin continues uninterrupted operation.

I've seen the request for log timestamping come from several people.  Log rotation is something I wanted for server operation.




Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1516579264
Hero Member
*
Offline Offline

Posts: 1516579264

View Profile Personal Message (Offline)

Ignore
1516579264
Reply with quote  #2

1516579264
Report to moderator
1516579264
Hero Member
*
Offline Offline

Posts: 1516579264

View Profile Personal Message (Offline)

Ignore
1516579264
Reply with quote  #2

1516579264
Report to moderator
1516579264
Hero Member
*
Offline Offline

Posts: 1516579264

View Profile Personal Message (Offline)

Ignore
1516579264
Reply with quote  #2

1516579264
Report to moderator
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1512


View Profile
March 03, 2011, 04:24:04 AM
#2


Separated out log timestamping at https://github.com/bitcoin/bitcoin/pull/91


Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Gavin Andresen
Legendary
*
qt
Offline Offline

Activity: 1652


Chief Scientist


View Profile WWW
March 03, 2011, 03:45:13 PM
#3

You can't open and close the file; it is not thread-safe (thread one closes fp and sets it to NULL and sleeps, thread two wakes up and uses a NULL fp).

And you can't wrap the open/close in a CRITICAL_SECTION, because logging happens at shutdown, CRITICAL_SECTION relies on a destructor to work properly, and you can't control the order in which C++ destructors are called during shutdown.

I learned all that the hard way a few releases back.

You can rotate the logs using the "copytruncate" feature of logrotate.

How often do you get the chance to work on a potentially world-changing project?
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1512


View Profile
March 03, 2011, 04:47:10 PM
#4

You can rotate the logs using the "copytruncate" feature of logrotate.

The logfile keeps expanding, under copytruncate, here.


Jeff Garzik, Bloq CEO, former bitcoin core dev team; opinions are my own.
Visit bloq.com / metronome.io
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!