progresslog

package
v0.0.0-...-e8e7bc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2023 License: ISC Imports: 4 Imported by: 0

README

progresslog

Build Status ISC License Doc

Package progresslog provides periodic logging for block processing.

Tests are included to ensure proper functionality.

Feature Overview

  • Maintains cumulative totals about blocks between each logging interval
    • Total number of blocks
    • Total number of transactions
    • Total number of votes
    • Total number of tickets
    • Total number of revocations
  • Logs all cumulative data every 10 seconds
  • Immediately logs any outstanding data when the provided sync height is reached

License

Package progresslog is licensed under the copyfree ISC License.

Documentation

Overview

Package progresslog provides periodic logging for block processing.

Tests are included to ensure proper functionality.

Feature Overview

The following are the primary features provided:

  • Maintains cumulative totals about blocks between each logging interval
  • Logs all cumulative data every 10 seconds
  • Immediately logs any outstanding data when requested by the caller

The cumulative totals include:

  • Total number of blocks
  • Total number of transactions
  • Total number of votes
  • Total number of tickets
  • Total number of revocations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Logger

type Logger struct {
	sync.Mutex
	// contains filtered or unexported fields
}

Logger provides periodic logging of progress towards some action such as syncing the chain.

func New

func New(progressAction string, logger slog.Logger) *Logger

New returns a new block progress logger.

func (*Logger) LogHeaderProgress

func (l *Logger) LogHeaderProgress(processedHeaders uint64, forceLog bool, progressFn func() float64)

LogHeaderProgress accumulates the provided number of processed headers and periodically (every 10 seconds) logs an information message to show the header sync progress to the user along with duration and totals included.

The force flag may be used to force a log message to be shown regardless of the time the last one was shown.

The progress message is templated as follows:

{progressAction} {numProcessed} {headers|header} in the last {timePeriod}
(progress {progress}%)

This function is safe for concurrent access.

func (*Logger) LogProgress

func (l *Logger) LogProgress(block *wire.MsgBlock, forceLog bool, progressFn func() float64)

LogProgress accumulates details for the provided block and periodically (every 10 seconds) logs an information message to show progress to the user along with duration and totals included.

The force flag may be used to force a log message to be shown regardless of the time the last one was shown.

The progress message is templated as follows:

{progressAction} {numProcessed} {blocks|block} in the last {timePeriod}
({numTxs} {transactions|transaction}, {numTickets} {tickets|ticket},
{numVotes} {votes|vote}, {numRevocations} {revocations|revocation},
height {lastBlockHeight}, progress {progress}%)

This function is safe for concurrent access.

func (*Logger) SetLastLogTime

func (l *Logger) SetLastLogTime(time time.Time)

SetLastLogTime updates the last time data was logged to the provided time.

This function is safe for concurrent access.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL