...

Source file src/k8s.io/kubernetes/test/e2e/framework/log.go

Documentation: k8s.io/kubernetes/test/e2e/framework

     1  /*
     2  Copyright 2019 The Kubernetes 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 framework
    18  
    19  import (
    20  	"fmt"
    21  
    22  	"github.com/onsi/ginkgo/v2"
    23  )
    24  
    25  // Logf logs the info.
    26  //
    27  // Use this instead of `klog.Infof` because stack unwinding automatically
    28  // skips over helper functions which marked themselves as helper by
    29  // calling [ginkgo.GinkgoHelper].
    30  func Logf(format string, args ...interface{}) {
    31  	log(1, fmt.Sprintf(format, args...))
    32  }
    33  
    34  // Failf logs the fail info, including a stack trace starts with its direct caller
    35  // (for example, for call chain f -> g -> Failf("foo", ...) error would be logged for "g").
    36  func Failf(format string, args ...interface{}) {
    37  	msg := fmt.Sprintf(format, args...)
    38  	skip := 1
    39  	ginkgo.Fail(msg, skip)
    40  	panic("unreachable")
    41  }
    42  
    43  // Fail is an alias for ginkgo.Fail.
    44  var Fail = ginkgo.Fail
    45  

View as plain text