diff --git a/pkg/containerengine/docker.go b/pkg/containerengine/docker.go index 935355349..ff42cb311 100644 --- a/pkg/containerengine/docker.go +++ b/pkg/containerengine/docker.go @@ -43,7 +43,7 @@ import ( type docker struct { cli *client.Client - syslog *localSyslog + logger ContainerLogger } var _ ContainerEngine = &docker{} @@ -287,10 +287,9 @@ func (d *docker) ContainerExec(containerName string, cmd []string, workingDir st } func (d *docker) Logger(stackPath string) ContainerLogger { - if d.syslog == nil { - d.syslog = &localSyslog{ - logPath: path.Join(utils.NitricLogDir(stackPath), "run.log"), - } + if d.logger != nil { + return d.logger } - return d.syslog + d.logger = newSyslog(path.Join(utils.NitricLogDir(stackPath), "run.log")) + return d.logger } diff --git a/pkg/containerengine/syslog.go b/pkg/containerengine/syslog_other.go similarity index 95% rename from pkg/containerengine/syslog.go rename to pkg/containerengine/syslog_other.go index 17cf641af..49462cc36 100644 --- a/pkg/containerengine/syslog.go +++ b/pkg/containerengine/syslog_other.go @@ -14,6 +14,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// +build !windows + package containerengine import ( @@ -38,6 +40,10 @@ type localSyslog struct { server *syslog.Server } +func newSyslog(logPath string) ContainerLogger { + return &localSyslog{logPath: logPath} +} + func (s *localSyslog) Stop() error { errList := utils.NewErrorList() diff --git a/pkg/containerengine/syslog_windows.go b/pkg/containerengine/syslog_windows.go new file mode 100644 index 000000000..729b27f8c --- /dev/null +++ b/pkg/containerengine/syslog_windows.go @@ -0,0 +1,37 @@ +// Copyright Nitric Pty Ltd. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build windows + +package containerengine + +import ( + "github.com/docker/docker/api/types/container" +) + +type nullLogger struct { +} + +func newSyslog(logPath string) ContainerLogger { + return &nullLogger{} +} + +func (n *nullLogger) Config() *container.LogConfig { + return &container.LogConfig{} +} + +func (n *nullLogger) Stop() error { return nil } +func (n *nullLogger) Start() error { return nil }