diff --git a/cmd/autosnap.go b/cmd/autosnap.go index 776c387..fe063a7 100644 --- a/cmd/autosnap.go +++ b/cmd/autosnap.go @@ -48,7 +48,7 @@ func (a *IntervalAutosnap) findSyncPoint(fss []*zfs.DatasetPath) (syncPoint time a.task.Log().Debug("examine filesystem state") for _, d := range fss { - l := a.task.Log().WithField(logFSField, d.ToString()) + l := a.task.Log().WithField("fs", d.ToString()) fsvs, err := zfs.ZFSListFilesystemVersions(d, NewPrefixFilter(a.Prefix)) if err != nil { @@ -175,7 +175,8 @@ func (a *IntervalAutosnap) doSnapshots(didSnaps chan struct{}) { suffix := time.Now().In(time.UTC).Format("20060102_150405_000") snapname := fmt.Sprintf("%s%s", a.Prefix, suffix) - l := a.task.Log().WithField(logFSField, d.ToString()). + l := a.task.Log(). + WithField("fs", d.ToString()). WithField("snapname", snapname) l.Info("create snapshot") diff --git a/cmd/config_job_pull.go b/cmd/config_job_pull.go index df6dab1..871166c 100644 --- a/cmd/config_job_pull.go +++ b/cmd/config_job_pull.go @@ -182,9 +182,9 @@ func (j *PullJob) doRun(ctx context.Context) { return } - ctx = replication.WithLogger(ctx, replicationLogAdaptor{j.task.Log().WithField("subsystem", "replication")}) - ctx = streamrpc.ContextWithLogger(ctx, streamrpcLogAdaptor{j.task.Log().WithField("subsystem", "rpc.protocol")}) - ctx = endpoint.WithLogger(ctx, j.task.Log().WithField("subsystem", "rpc.endpoint")) + ctx = replication.WithLogger(ctx, replicationLogAdaptor{j.task.Log().WithField(logSubsysField, "replication")}) + ctx = streamrpc.ContextWithLogger(ctx, streamrpcLogAdaptor{j.task.Log().WithField(logSubsysField, "rpc.protocol")}) + ctx = endpoint.WithLogger(ctx, j.task.Log().WithField(logSubsysField, "rpc.endpoint")) j.rep = replication.NewReplication() j.rep.Drive(ctx, sender, puller) diff --git a/cmd/config_job_source.go b/cmd/config_job_source.go index c79d3c9..200b01d 100644 --- a/cmd/config_job_source.go +++ b/cmd/config_job_source.go @@ -209,8 +209,8 @@ func (j *SourceJob) handleConnection(conn net.Conn, task *Task) { senderEP := endpoint.NewSender(j.Filesystems, NewPrefixFilter(j.SnapshotPrefix)) ctx := context.Background() - ctx = context.WithValue(ctx, contextKeyLog, task.Log().WithField("subsystem", "rpc.endpoint")) - ctx = streamrpc.ContextWithLogger(ctx, streamrpcLogAdaptor{task.Log().WithField("subsystem", "rpc.protocol")}) + ctx = context.WithValue(ctx, contextKeyLog, task.Log().WithField(logSubsysField, "rpc.endpoint")) + ctx = streamrpc.ContextWithLogger(ctx, streamrpcLogAdaptor{task.Log().WithField(logSubsysField, "rpc.protocol")}) handler := endpoint.NewHandler(senderEP) if err := streamrpc.ServeConn(ctx, conn, STREAMRPC_CONFIG, handler.Handle); err != nil { task.Log().WithError(err).Error("error serving connection") diff --git a/cmd/logging_formatters.go b/cmd/logging_formatters.go index 02795e8..444f3d3 100644 --- a/cmd/logging_formatters.go +++ b/cmd/logging_formatters.go @@ -22,14 +22,9 @@ const ( ) const ( - logJobField string = "job" - logTaskField string = "task" - logFSField string = "filesystem" - logSubsysField string = "subsystem" - logMapFromField string = "map_from" - logMapToField string = "map_to" - logIncFromField string = "inc_from" - logIncToField string = "inc_to" + logJobField string = "job" + logTaskField string = "task" + logSubsysField string = "subsystem" ) type NoFormatter struct{} @@ -91,19 +86,6 @@ func (f *HumanFormatter) Format(e *logger.Entry) (out []byte, err error) { break } } - // even more prefix fields - //mapFrom, mapFromOk := e.Fields[logMapFromField].(string) - //mapTo, mapToOk := e.Fields[logMapToField].(string) - //if mapFromOk && mapToOk && !f.ignored(logMapFromField) && !f.ignored(logMapToField) { - // fmt.Fprintf(&line, "[%s => %s]", mapFrom, mapTo) - // prefixed[logMapFromField], prefixed[logMapToField] = true, true - //} - //incFrom, incFromOk := e.Fields[logIncFromField].(string) - //incTo, incToOk := e.Fields[logIncToField].(string) - //if incFromOk && incToOk && !f.ignored(logIncFromField) && !f.ignored(logMapToField) { - // fmt.Fprintf(&line, "[%s => %s]", incFrom, incTo) - // prefixed[logIncFromField], prefixed[logIncToField] = true, true - //} if line.Len() > 0 { fmt.Fprint(&line, ": ") diff --git a/cmd/prune.go b/cmd/prune.go index 73ea7e1..82d4425 100644 --- a/cmd/prune.go +++ b/cmd/prune.go @@ -41,7 +41,7 @@ func (p *Pruner) filterFilesystems() (filesystems []*zfs.DatasetPath, stop bool) func (p *Pruner) filterVersions(fs *zfs.DatasetPath) (fsversions []zfs.FilesystemVersion, stop bool) { p.task.Enter("filter_versions") defer p.task.Finish() - log := p.task.Log().WithField(logFSField, fs.ToString()) + log := p.task.Log().WithField("fs", fs.ToString()) filter := NewPrefixFilter(p.SnapshotPrefix) fsversions, err := zfs.ZFSListFilesystemVersions(fs, filter) @@ -59,7 +59,7 @@ func (p *Pruner) filterVersions(fs *zfs.DatasetPath) (fsversions []zfs.Filesyste func (p *Pruner) pruneFilesystem(fs *zfs.DatasetPath) (r PruneResult, valid bool) { p.task.Enter("prune_fs") defer p.task.Finish() - log := p.task.Log().WithField(logFSField, fs.ToString()) + log := p.task.Log().WithField("fs", fs.ToString()) fsversions, stop := p.filterVersions(fs) if stop {