Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix logs with configuration #880

Merged
merged 3 commits into from
Apr 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions commands/provider/service_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/mesg-foundation/core/commands/provider/assets"
"github.com/mesg-foundation/core/protobuf/acknowledgement"
"github.com/mesg-foundation/core/protobuf/coreapi"
"github.com/mesg-foundation/core/service"
"github.com/mesg-foundation/core/service/importer"
"github.com/mesg-foundation/core/utils/chunker"
"github.com/mesg-foundation/core/utils/pretty"
Expand Down Expand Up @@ -117,6 +118,7 @@ func (p *ServiceProvider) ServiceLogs(id string, dependencies ...string) (logs [
if err != nil {
return nil, nil, nil, err
}
dependencies = append(dependencies, service.MainServiceKey)
for _, dep := range resp.Service.Definition.Dependencies {
dependencies = append(dependencies, dep.Key)
}
Expand Down
2 changes: 2 additions & 0 deletions commands/service_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strings"

"github.com/mesg-foundation/core/commands/provider"
"github.com/mesg-foundation/core/service"
"github.com/mesg-foundation/core/utils/pretty"
"github.com/mesg-foundation/core/x/xsignal"
"github.com/mesg-foundation/core/x/xstrings"
Expand Down Expand Up @@ -69,6 +70,7 @@ func showLogs(e ServiceExecutor, serviceID string, dependencies ...string) (clos
// if there was no dependencies copy all returned
// by service logs.
if len(dependencies) == 0 {
dependencies = append(dependencies, service.MainServiceKey)
for _, log := range logs {
dependencies = append(dependencies, log.Dependency)
}
Expand Down
19 changes: 15 additions & 4 deletions service/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,29 @@ func (s *Service) Logs(c container.Container, dependencies ...string) ([]*Log, e
logs []*Log
isNoFilter = len(dependencies) == 0
)
for _, dep := range s.Dependencies {
if isNoFilter || xstrings.SliceContains(dependencies, dep.Key) {
addLog := func(dep *Dependency, name string) error {
if isNoFilter || xstrings.SliceContains(dependencies, name) {
rstd, rerr, err := dep.Logs(c, s.namespace())
if err != nil {
return nil, err
return err
}
logs = append(logs, &Log{
Dependency: dep.Key,
Dependency: name,
Standard: rstd,
Error: rerr,
})
}
return nil
}
if s.Configuration != nil {
if err := addLog(s.Configuration, MainServiceKey); err != nil {
return nil, err
}
}
for _, dep := range s.Dependencies {
if err := addLog(dep, dep.Key); err != nil {
return nil, err
}
}
return logs, nil
}