Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit 6c2d0a3

Browse files
authored
Merge pull request #21 from portainer/fix/EE-2825/logging-improvements
fix(logging): improve the log output EE-2825
2 parents cec58db + 64c0851 commit 6c2d0a3

File tree

3 files changed

+37
-7
lines changed

3 files changed

+37
-7
lines changed

compose/compose.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func NewComposeDeployer(binaryPath, configPath string) (libstack.Deployer, error
1818
}
1919

2020
if err == errors.ErrBinaryNotFound {
21-
log.Printf("[INFO] [main,compose] [message: binary is missing, falling-back to compose plugin] [error: %s]", err)
21+
log.Printf("[INFO] [compose] [message: binary is missing, falling-back to compose plugin] [error: %s]", err)
2222
return composeplugin.NewPluginWrapper(binaryPath, configPath)
2323
}
2424

compose/internal/composebinary/composebinary.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ func NewComposeWrapper(binaryPath, configPath string) (libstack.Deployer, error)
3535
func (wrapper *ComposeWrapper) Deploy(ctx context.Context, workingDir, host, projectName string, filePaths []string, envFilePath string, forceRereate bool) error {
3636
output, err := wrapper.Command(newUpCommand(filePaths, forceRereate), workingDir, host, projectName, envFilePath)
3737
if len(output) != 0 {
38-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
38+
if err != nil {
39+
return err
40+
}
41+
42+
log.Printf("[INFO] [compose,internal,composebinary] [message: Stack deployment successful]")
43+
log.Printf("[DEBUG] [compose,internal,composebinary] [output: %s]", output)
3944
}
4045

4146
return err
@@ -45,7 +50,12 @@ func (wrapper *ComposeWrapper) Deploy(ctx context.Context, workingDir, host, pro
4550
func (wrapper *ComposeWrapper) Remove(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
4651
output, err := wrapper.Command(newDownCommand(filePaths), workingDir, host, projectName, "")
4752
if len(output) != 0 {
48-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
53+
if err != nil {
54+
return err
55+
}
56+
57+
log.Printf("[INFO] [compose,internal,composebinary] [message: Stack removal successful]")
58+
log.Printf("[DEBUG] [compose,internal,composebinary] [output: %s]", output)
4959
}
5060

5161
return err
@@ -56,7 +66,12 @@ func (wrapper *ComposeWrapper) Remove(ctx context.Context, workingDir, host, pro
5666
func (wrapper *ComposeWrapper) Pull(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
5767
output, err := wrapper.Command(newPullCommand(filePaths), workingDir, host, projectName, "")
5868
if len(output) != 0 {
59-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
69+
if err != nil {
70+
return err
71+
}
72+
73+
log.Printf("[INFO] [compose,internal,composebinary] [message: Stack pull successful]")
74+
log.Printf("[DEBUG] [compose,internal,composebinary] [output: %s]", output)
6075
}
6176

6277
return err

compose/internal/composeplugin/composeplugin.go

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,12 @@ func NewPluginWrapper(binaryPath, configPath string) (libstack.Deployer, error)
6565
func (wrapper *PluginWrapper) Deploy(ctx context.Context, workingDir, host, projectName string, filePaths []string, envFilePath string, forceRereate bool) error {
6666
output, err := wrapper.command(newUpCommand(filePaths, forceRereate), workingDir, host, projectName, envFilePath)
6767
if len(output) != 0 {
68-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
68+
if err != nil {
69+
return err
70+
}
71+
72+
log.Printf("[INFO] [compose,internal,composeplugin] [message: Stack deployment successful]")
73+
log.Printf("[DEBUG] [compose,internal,composeplugin] [output: %s]", output)
6974
}
7075

7176
return err
@@ -75,7 +80,12 @@ func (wrapper *PluginWrapper) Deploy(ctx context.Context, workingDir, host, proj
7580
func (wrapper *PluginWrapper) Remove(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
7681
output, err := wrapper.command(newDownCommand(filePaths), workingDir, host, projectName, "")
7782
if len(output) != 0 {
78-
log.Printf("[libstack,composebinary] [message: finish deploying] [output: %s] [err: %s]", output, err)
83+
if err != nil {
84+
return err
85+
}
86+
87+
log.Printf("[INFO] [compose,internal,composeplugin] [message: Stack removal successful]")
88+
log.Printf("[DEBUG] [compose,internal,composeplugin] [output: %s]", output)
7989
}
8090

8191
return err
@@ -85,7 +95,12 @@ func (wrapper *PluginWrapper) Remove(ctx context.Context, workingDir, host, proj
8595
func (wrapper *PluginWrapper) Pull(ctx context.Context, workingDir, host, projectName string, filePaths []string) error {
8696
output, err := wrapper.command(newPullCommand(filePaths), workingDir, host, projectName, "")
8797
if len(output) != 0 {
88-
log.Printf("[libstack,composebinary] [message: finish pulling] [output: %s] [err: %s]", output, err)
98+
if err != nil {
99+
return err
100+
}
101+
102+
log.Printf("[INFO] [compose,internal,composeplugin] [message: Stack pull successful]")
103+
log.Printf("[DEBUG] [compose,internal,composeplugin] [output: %s]", output)
89104
}
90105

91106
return err

0 commit comments

Comments
 (0)