forked from LaconicNetwork/kompose
vendoring dependencies
This commit is contained in:
+26
-2
@@ -1,5 +1,9 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// NullLogger is a logger.Logger and logger.Factory implementation that does nothing.
|
||||
type NullLogger struct {
|
||||
}
|
||||
@@ -12,7 +16,27 @@ func (n *NullLogger) Out(_ []byte) {
|
||||
func (n *NullLogger) Err(_ []byte) {
|
||||
}
|
||||
|
||||
// Create implements logger.Factory and returns a NullLogger.
|
||||
func (n *NullLogger) Create(_ string) Logger {
|
||||
// CreateContainerLogger allows NullLogger to implement logger.Factory.
|
||||
func (n *NullLogger) CreateContainerLogger(_ string) Logger {
|
||||
return &NullLogger{}
|
||||
}
|
||||
|
||||
// CreateBuildLogger allows NullLogger to implement logger.Factory.
|
||||
func (n *NullLogger) CreateBuildLogger(_ string) Logger {
|
||||
return &NullLogger{}
|
||||
}
|
||||
|
||||
// CreatePullLogger allows NullLogger to implement logger.Factory.
|
||||
func (n *NullLogger) CreatePullLogger(_ string) Logger {
|
||||
return &NullLogger{}
|
||||
}
|
||||
|
||||
// OutWriter returns the base writer
|
||||
func (n *NullLogger) OutWriter() io.Writer {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ErrWriter returns the base writer
|
||||
func (n *NullLogger) ErrWriter() io.Writer {
|
||||
return nil
|
||||
}
|
||||
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
)
|
||||
|
||||
// RawLogger is a logger.Logger and logger.Factory implementation that prints raw data with no formatting.
|
||||
type RawLogger struct {
|
||||
}
|
||||
|
||||
// Out is a no-op function.
|
||||
func (r *RawLogger) Out(message []byte) {
|
||||
fmt.Print(string(message))
|
||||
|
||||
}
|
||||
|
||||
// Err is a no-op function.
|
||||
func (r *RawLogger) Err(message []byte) {
|
||||
fmt.Fprint(os.Stderr, string(message))
|
||||
|
||||
}
|
||||
|
||||
// CreateContainerLogger allows RawLogger to implement logger.Factory.
|
||||
func (r *RawLogger) CreateContainerLogger(_ string) Logger {
|
||||
return &RawLogger{}
|
||||
}
|
||||
|
||||
// CreateBuildLogger allows RawLogger to implement logger.Factory.
|
||||
func (r *RawLogger) CreateBuildLogger(_ string) Logger {
|
||||
return &RawLogger{}
|
||||
}
|
||||
|
||||
// CreatePullLogger allows RawLogger to implement logger.Factory.
|
||||
func (r *RawLogger) CreatePullLogger(_ string) Logger {
|
||||
return &RawLogger{}
|
||||
}
|
||||
|
||||
// OutWriter returns the base writer
|
||||
func (r *RawLogger) OutWriter() io.Writer {
|
||||
return os.Stdout
|
||||
}
|
||||
|
||||
// ErrWriter returns the base writer
|
||||
func (r *RawLogger) ErrWriter() io.Writer {
|
||||
return os.Stderr
|
||||
}
|
||||
+10
-2
@@ -1,15 +1,23 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// Factory defines methods a factory should implement, to create a Logger
|
||||
// based on the specified name.
|
||||
// based on the specified container, image or service name.
|
||||
type Factory interface {
|
||||
Create(name string) Logger
|
||||
CreateContainerLogger(name string) Logger
|
||||
CreateBuildLogger(name string) Logger
|
||||
CreatePullLogger(name string) Logger
|
||||
}
|
||||
|
||||
// Logger defines methods to implement for being a logger.
|
||||
type Logger interface {
|
||||
Out(bytes []byte)
|
||||
Err(bytes []byte)
|
||||
OutWriter() io.Writer
|
||||
ErrWriter() io.Writer
|
||||
}
|
||||
|
||||
// Wrapper is a wrapper around Logger that implements the Writer interface,
|
||||
|
||||
Reference in New Issue
Block a user