Bitcoin Forum
April 23, 2018, 01:54:33 PM *
News: Latest stable version of Bitcoin Core: 0.16.0  [Torrent]. (New!)
 
   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
Merit: 1001


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
Even in the event that an attacker gains more than 50% of the network's computational power, only transactions sent by the attacker could be reversed or double-spent. The network would not be destroyed.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1524491673
Hero Member
*
Offline Offline

Posts: 1524491673

View Profile Personal Message (Offline)

Ignore
1524491673
Reply with quote  #2

1524491673
Report to moderator
1524491673
Hero Member
*
Offline Offline

Posts: 1524491673

View Profile Personal Message (Offline)

Ignore
1524491673
Reply with quote  #2

1524491673
Report to moderator
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1512
Merit: 1001


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
Merit: 1012


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
Merit: 1001


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!