github.com/NVIDIA/aistore@v1.3.23-0.20240517131212-7df6609be51d/cmn/cos/log.go (about)

     1  // Package cos provides common low-level types and utilities for all aistore projects.
     2  /*
     3   * Copyright (c) 2018-2024, NVIDIA CORPORATION. All rights reserved.
     4   */
     5  package cos
     6  
     7  import (
     8  	"flag"
     9  	"fmt"
    10  	"os"
    11  
    12  	"github.com/NVIDIA/aistore/cmn/nlog"
    13  )
    14  
    15  func Infof(format string, a ...any) {
    16  	if flag.Parsed() {
    17  		nlog.InfoDepth(1, fmt.Sprintf(format, a...))
    18  	} else {
    19  		fmt.Printf(format+"\n", a...)
    20  	}
    21  }
    22  
    23  func Errorf(format string, a ...any) {
    24  	if flag.Parsed() {
    25  		nlog.ErrorDepth(1, fmt.Sprintf(format, a...))
    26  	} else {
    27  		fmt.Fprintf(os.Stderr, format+"\n", a...)
    28  	}
    29  }