Skip to content

Commit

Permalink
Add additional log statements
Browse files Browse the repository at this point in the history
During my first tests I noticed that it is very hard to actually gauge
if rsched is used and configured correctly. Those additional log
statemetnts should help with that.
  • Loading branch information
fhofherr committed Dec 26, 2021
1 parent 454013d commit d690870
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.1.0-alpha.2] - 2021-12-26

* Add additional log statements to make debugging easier.

## [0.1.0-alpha.1] - 2021-12-26

### Added
Expand All @@ -17,6 +21,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
docker images. Currently only `linux/amd64` is supported.
`linux/arm64` will be supported once I have the ability to test it.

[Unreleased]: https://github.com/fhofherr/rsched/compare/v0.1.0-alpha.1...HEAD
[Unreleased]: https://github.com/fhofherr/rsched/compare/v0.1.0-alpha.2...HEAD
[0.1.0-alpha.2]: https://github.com/fhofherr/rsched/compare/v0.1.0-alpha.1...v0.1.0-alpha.2
[0.1.0-alpha.1]: https://github.com/fhofherr/rsched/compare/v0.0.0...v0.1.0-alpha.1
[0.0.0]: https://github.com/fhofherr/rsched/releases/tag/v0.0.0
1 change: 1 addition & 0 deletions internal/cmd/rsched.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ type RSched struct {
func (r *RSched) Run(cfg Config) {
env := Environ()

log.Printf("Rsched version %s", Version)
if cfg.ResticRepository != "" && env[restic.EnvResticRepository] == "" {
env[restic.EnvResticRepository] = cfg.ResticRepository
}
Expand Down
4 changes: 4 additions & 0 deletions internal/restic/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,17 @@ type Scheduler struct {
// See the documentation of the Scheduler type for the definition of schedule.
func (s *Scheduler) ScheduleBackup(schedule, path string, os ...Option) error {
return s.scheduleFunc(schedule, func(ctx context.Context) {
log.Println("Beginning backup")
if err := s.BackupFunc(ctx, path, os...); err != nil {
var rErr Error

log.Printf("Error during backup: %v", err)
if errors.As(err, &rErr) && len(rErr.Stderr) > 0 {
log.Printf("Restic stderr: %s", string(rErr.Stderr))
}
return
}
log.Println("Backup successfully completed")
})
}

Expand Down Expand Up @@ -79,6 +82,7 @@ func (s *Scheduler) Shutdown() {
func (s *Scheduler) scheduleFunc(schedule string, f func(context.Context)) error {
s.init()

log.Printf("Adding job with schedule %q", schedule)
job := s.newJob(f)
if schedule == ScheduleOnce {
go job()
Expand Down

0 comments on commit d690870

Please sign in to comment.