Bitcoin Forum
April 20, 2024, 12:32:13 AM *
News: Latest Bitcoin Core release: 26.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [PULL] Improve debug logging  (Read 1095 times)
jgarzik (OP)
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


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
1713573133
Hero Member
*
Offline Offline

Posts: 1713573133

View Profile Personal Message (Offline)

Ignore
1713573133
Reply with quote  #2

1713573133
Report to moderator
1713573133
Hero Member
*
Offline Offline

Posts: 1713573133

View Profile Personal Message (Offline)

Ignore
1713573133
Reply with quote  #2

1713573133
Report to moderator
"This isn't the kind of software where we can leave so many unresolved bugs that we need a tracker for them." -- Satoshi
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1713573133
Hero Member
*
Offline Offline

Posts: 1713573133

View Profile Personal Message (Offline)

Ignore
1713573133
Reply with quote  #2

1713573133
Report to moderator
1713573133
Hero Member
*
Offline Offline

Posts: 1713573133

View Profile Personal Message (Offline)

Ignore
1713573133
Reply with quote  #2

1713573133
Report to moderator
1713573133
Hero Member
*
Offline Offline

Posts: 1713573133

View Profile Personal Message (Offline)

Ignore
1713573133
Reply with quote  #2

1713573133
Report to moderator
jgarzik (OP)
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


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: 2216


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 (OP)
Legendary
*
qt
Offline Offline

Activity: 1596
Merit: 1091


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:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!