github.com/codingfuture/orig-energi3@v0.8.4/swarm/log/log.go (about)

     1  // Copyright 2018 The Energi Core Authors
     2  // Copyright 2018 The go-ethereum Authors
     3  // This file is part of the Energi Core library.
     4  //
     5  // The Energi Core library is free software: you can redistribute it and/or modify
     6  // it under the terms of the GNU Lesser General Public License as published by
     7  // the Free Software Foundation, either version 3 of the License, or
     8  // (at your option) any later version.
     9  //
    10  // The Energi Core library is distributed in the hope that it will be useful,
    11  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  // GNU Lesser General Public License for more details.
    14  //
    15  // You should have received a copy of the GNU Lesser General Public License
    16  // along with the Energi Core library. If not, see <http://www.gnu.org/licenses/>.
    17  
    18  package log
    19  
    20  import (
    21  	l "github.com/ethereum/go-ethereum/log"
    22  	"github.com/ethereum/go-ethereum/metrics"
    23  )
    24  
    25  const (
    26  	// CallDepth is set to 1 in order to influence to reported line number of
    27  	// the log message with 1 skipped stack frame of calling l.Output()
    28  	CallDepth = 1
    29  )
    30  
    31  // Warn is a convenient alias for log.Warn with stats
    32  func Warn(msg string, ctx ...interface{}) {
    33  	metrics.GetOrRegisterCounter("warn", nil).Inc(1)
    34  	l.Output(msg, l.LvlWarn, CallDepth, ctx...)
    35  }
    36  
    37  // Error is a convenient alias for log.Error with stats
    38  func Error(msg string, ctx ...interface{}) {
    39  	metrics.GetOrRegisterCounter("error", nil).Inc(1)
    40  	l.Output(msg, l.LvlError, CallDepth, ctx...)
    41  }
    42  
    43  // Crit is a convenient alias for log.Crit with stats
    44  func Crit(msg string, ctx ...interface{}) {
    45  	metrics.GetOrRegisterCounter("crit", nil).Inc(1)
    46  	l.Output(msg, l.LvlCrit, CallDepth, ctx...)
    47  }
    48  
    49  // Info is a convenient alias for log.Info with stats
    50  func Info(msg string, ctx ...interface{}) {
    51  	metrics.GetOrRegisterCounter("info", nil).Inc(1)
    52  	l.Output(msg, l.LvlInfo, CallDepth, ctx...)
    53  }
    54  
    55  // Debug is a convenient alias for log.Debug with stats
    56  func Debug(msg string, ctx ...interface{}) {
    57  	metrics.GetOrRegisterCounter("debug", nil).Inc(1)
    58  	l.Output(msg, l.LvlDebug, CallDepth, ctx...)
    59  }
    60  
    61  // Trace is a convenient alias for log.Trace with stats
    62  func Trace(msg string, ctx ...interface{}) {
    63  	metrics.GetOrRegisterCounter("trace", nil).Inc(1)
    64  	l.Output(msg, l.LvlTrace, CallDepth, ctx...)
    65  }