mirror of
https://github.com/SSLMate/certspotter.git
synced 2025-06-27 10:15:33 +02:00
Improve verbose logging
This commit is contained in:
parent
b89afef32a
commit
46c8fc64fd
@ -75,7 +75,7 @@ func (daemon *daemon) startTask(ctx context.Context, ctlog *loglist.Log) task {
|
|||||||
defer cancel()
|
defer cancel()
|
||||||
err := monitorLogContinously(ctx, daemon.config, ctlog)
|
err := monitorLogContinously(ctx, daemon.config, ctlog)
|
||||||
if daemon.config.Verbose {
|
if daemon.config.Verbose {
|
||||||
log.Printf("task for log %s stopped with error %s", ctlog.GetMonitoringURL(), err)
|
log.Printf("%s: task stopped with error: %s", ctlog.GetMonitoringURL(), err)
|
||||||
}
|
}
|
||||||
if ctx.Err() == context.Canceled && errors.Is(err, context.Canceled) {
|
if ctx.Err() == context.Canceled && errors.Is(err, context.Canceled) {
|
||||||
return nil
|
return nil
|
||||||
|
@ -246,17 +246,18 @@ func monitorLogContinously(ctx context.Context, config *Config, ctlog *loglist.L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if config.Verbose {
|
if config.Verbose {
|
||||||
log.Printf("brand new log %s (starting from %d)", ctlog.GetMonitoringURL(), state.DownloadPosition.Size())
|
log.Printf("%s: monitoring brand new log starting from position %d", ctlog.GetMonitoringURL(), state.DownloadPosition.Size())
|
||||||
}
|
}
|
||||||
if err := config.State.StoreLogState(ctx, ctlog.LogID, state); err != nil {
|
if err := config.State.StoreLogState(ctx, ctlog.LogID, state); err != nil {
|
||||||
return fmt.Errorf("error storing log state: %w", err)
|
return fmt.Errorf("error storing log state: %w", err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if config.Verbose {
|
||||||
|
log.Printf("%s: resuming monitoring from position %d", ctlog.GetMonitoringURL(), state.DownloadPosition.Size())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defer func() {
|
defer func() {
|
||||||
if config.Verbose {
|
|
||||||
log.Printf("saving state in defer for %s", ctlog.GetMonitoringURL())
|
|
||||||
}
|
|
||||||
storeCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
storeCtx, cancel := context.WithTimeout(context.Background(), 15*time.Second)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
if err := config.State.StoreLogState(storeCtx, ctlog.LogID, state); err != nil && returnedErr == nil {
|
if err := config.State.StoreLogState(storeCtx, ctlog.LogID, state); err != nil && returnedErr == nil {
|
||||||
@ -503,6 +504,9 @@ func saveStateWorker(ctx context.Context, config *Config, ctlog *loglist.Log, st
|
|||||||
if err := config.State.RemoveSTH(ctx, ctlog.LogID, &sth.SignedTreeHead); err != nil {
|
if err := config.State.RemoveSTH(ctx, ctlog.LogID, &sth.SignedTreeHead); err != nil {
|
||||||
return fmt.Errorf("error removing verified STH: %w", err)
|
return fmt.Errorf("error removing verified STH: %w", err)
|
||||||
}
|
}
|
||||||
|
if config.Verbose {
|
||||||
|
log.Printf("%s: verified position is now %d", ctlog.GetMonitoringURL(), sth.SignedTreeHead.TreeSize)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(batch.entries) == 0 {
|
if len(batch.entries) == 0 {
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user