github.com/GoogleContainerTools/skaffold@v1.39.18/pkg/skaffold/log/log.go (about)

     1  /*
     2  Copyright 2021 The Skaffold Authors
     3  
     4  Licensed under the Apache License, Version 2.0 (the "License");
     5  you may not use this file except in compliance with the License.
     6  You may obtain a copy of the License at
     7  
     8      http://www.apache.org/licenses/LICENSE-2.0
     9  
    10  Unless required by applicable law or agreed to in writing, software
    11  distributed under the License is distributed on an "AS IS" BASIS,
    12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    13  See the License for the specific language governing permissions and
    14  limitations under the License.
    15  */
    16  
    17  package log
    18  
    19  import (
    20  	"context"
    21  	"io"
    22  	"time"
    23  
    24  	"github.com/GoogleContainerTools/skaffold/pkg/skaffold/graph"
    25  )
    26  
    27  // Logger defines the behavior of the object that retrieves logs from deployed resources.
    28  // Logger implementations are platform-specific, and are controlled by a single Deployer.
    29  type Logger interface {
    30  	// Start starts the logger.
    31  	Start(context.Context, io.Writer) error
    32  
    33  	// Stop stops the logger.
    34  	Stop()
    35  
    36  	// Mute mutes the logger.
    37  	Mute()
    38  
    39  	// Unmute unmutes the logger.
    40  	Unmute()
    41  
    42  	// SetSince sets the original timestamp for the logger.
    43  	SetSince(time.Time)
    44  
    45  	// RegisterArtifacts tracks build artifacts inside of a logger.
    46  	// The logger sometimes uses information about the currently deployed artifacts
    47  	// to actually retrieve logs (e.g. the Kubernetes PodSelector). Thus, we need to
    48  	// track the current build artifacts in the logger.
    49  	RegisterArtifacts([]graph.Artifact)
    50  }
    51  
    52  // NoopLogger is used in tests. It will never retrieve any logs from any resources.
    53  type NoopLogger struct{}
    54  
    55  func (n *NoopLogger) Start(context.Context, io.Writer) error { return nil }
    56  
    57  func (n *NoopLogger) Stop() {}
    58  
    59  func (n *NoopLogger) Mute() {}
    60  
    61  func (n *NoopLogger) Unmute() {}
    62  
    63  func (n *NoopLogger) SetSince(time.Time) {}
    64  
    65  func (n *NoopLogger) RegisterArtifacts(_ []graph.Artifact) {}