Improve logging

This commit is contained in:
Frederik Ring 2024-01-29 16:20:50 +01:00
parent 7d489a95e3
commit 87ea8d0930

View File

@ -170,6 +170,7 @@ func (s *script) stopContainersAndServices() (func() error, error) {
}
}
if isDockerSwarm {
s.logger.Info(
fmt.Sprintf(
"Stopping %d out of %d running container(s) and scaling down %d out of %d active service(s) as they were labeled %s.",
@ -180,6 +181,16 @@ func (s *script) stopContainersAndServices() (func() error, error) {
filterMatchLabel,
),
)
} else {
s.logger.Info(
fmt.Sprintf(
"Stopping %d out of %d running container(s) as they were labeled %s.",
len(containersToStop),
len(allContainers),
filterMatchLabel,
),
)
}
var stoppedContainers []types.Container
var stopErrors []error
@ -309,6 +320,7 @@ func (s *script) stopContainersAndServices() (func() error, error) {
errors.Join(allErrors...),
)
}
if isDockerSwarm {
s.logger.Info(
fmt.Sprintf(
"Restarted %d container(s) and %d service(s).",
@ -316,6 +328,15 @@ func (s *script) stopContainersAndServices() (func() error, error) {
len(scaledDownServices),
),
)
} else {
s.logger.Info(
fmt.Sprintf(
"Restarted %d container(s).",
len(stoppedContainers),
),
)
}
return nil
}, initialErr
}