Bitcoin Forum
December 11, 2016, 02:33:06 AM *
News: Latest stable version of Bitcoin Core: 0.13.1  [Torrent].
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [PULL] Improve debug logging  (Read 887 times)
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


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, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
Donations / tip jar: 1BrufViLKnSWtuWGkryPsKsxonV2NQ7Tcj
1481423586
Hero Member
*
Offline Offline

Posts: 1481423586

View Profile Personal Message (Offline)

Ignore
1481423586
Reply with quote  #2

1481423586
Report to moderator
1481423586
Hero Member
*
Offline Offline

Posts: 1481423586

View Profile Personal Message (Offline)

Ignore
1481423586
Reply with quote  #2

1481423586
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481423586
Hero Member
*
Offline Offline

Posts: 1481423586

View Profile Personal Message (Offline)

Ignore
1481423586
Reply with quote  #2

1481423586
Report to moderator
1481423586
Hero Member
*
Offline Offline

Posts: 1481423586

View Profile Personal Message (Offline)

Ignore
1481423586
Reply with quote  #2

1481423586
Report to moderator
jgarzik
Legendary
*
qt
Offline Offline

Activity: 1470


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


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


Jeff Garzik, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
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: 1470


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, bitcoin core dev team and BitPay engineer; opinions are my own, not my employer.
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!