mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-02 15:10:46 +00:00
modernise: Run new gopls modernise tool against the codebase and fix minor issues (#1826)
* modernise: Run new gopls modernise tool against codebase
* Address shazbert's nits
* apichecker, gctcli: Simplify HTML scraping functions and improve depth limit handling
* refactor: Create minSyncInterval const and update order book limit handling for binance and binanceUS
* refactor: Various slice usage improvements and rename TODO
* tranches: Revert deleteByID changes due to performance decrease
Shazbert was a F1 driver in a past lifetime 🏎️
* tranches: Simply retrieve copy
Thanks to shazbert
* documentation: Sort contributors list by contributions
* tranches: Remove deadcode in deleteByID
This commit is contained in:
@@ -4,7 +4,7 @@ import "testing"
|
||||
|
||||
func TestSetCustomLoghook(t *testing.T) {
|
||||
t.Parallel()
|
||||
logHook := func(_, _ string, _ ...interface{}) (bypassLibraryLogSystem bool) {
|
||||
logHook := func(_, _ string, _ ...any) (bypassLibraryLogSystem bool) {
|
||||
return false
|
||||
}
|
||||
SetCustomLogHook(logHook)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"slices"
|
||||
"time"
|
||||
|
||||
"github.com/thrasher-corp/gocryptotrader/encoding/json"
|
||||
@@ -100,7 +101,7 @@ type deferral func() string
|
||||
// StageLogEvent stages a new logger event in a jobs channel to be processed by
|
||||
// a worker pool. This segregates the need to process the log string and the
|
||||
// writes to the required io.Writer.
|
||||
func (mw *multiWriterHolder) StageLogEvent(fn deferral, header, slName, spacer, timestampFormat, instance, level string, showLogSystemName, bypassWarning, structuredLog bool, fields map[Key]interface{}) {
|
||||
func (mw *multiWriterHolder) StageLogEvent(fn deferral, header, slName, spacer, timestampFormat, instance, level string, showLogSystemName, bypassWarning, structuredLog bool, fields map[Key]any) {
|
||||
newJob := jobsPool.Get().(*job) //nolint:forcetypeassert // Not necessary from a pool
|
||||
newJob.Writers = mw.writers
|
||||
newJob.fn = fn
|
||||
@@ -143,11 +144,11 @@ func (mw *multiWriterHolder) add(writer io.Writer) error {
|
||||
if writer == nil {
|
||||
return errWriterIsNil
|
||||
}
|
||||
for i := range mw.writers {
|
||||
if mw.writers[i] == writer {
|
||||
return errWriterAlreadyLoaded
|
||||
}
|
||||
|
||||
if slices.Contains(mw.writers, writer) {
|
||||
return errWriterAlreadyLoaded
|
||||
}
|
||||
|
||||
mw.writers = append(mw.writers, writer)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -26,12 +26,12 @@ var (
|
||||
// GlobalLogFile hold global configuration options for file logger
|
||||
globalLogFile = &Rotate{}
|
||||
|
||||
jobsPool = &sync.Pool{New: func() interface{} { return new(job) }}
|
||||
jobsPool = &sync.Pool{New: func() any { return new(job) }}
|
||||
jobsChannel = make(chan *job, defaultJobChannelCapacity)
|
||||
|
||||
// Note: Logger state within logFields will be persistent until it's garbage
|
||||
// collected. This is a little bit more efficient.
|
||||
logFieldsPool = &sync.Pool{New: func() interface{} { return &fields{logger: logger} }}
|
||||
logFieldsPool = &sync.Pool{New: func() any { return &fields{logger: logger} }}
|
||||
|
||||
// LogPath system path to store log files in
|
||||
logPath string
|
||||
@@ -49,7 +49,7 @@ type job struct {
|
||||
TimestampFormat string
|
||||
ShowLogSystemName bool
|
||||
Instance string
|
||||
StructuredFields map[Key]interface{}
|
||||
StructuredFields map[Key]any
|
||||
StructuredLogging bool
|
||||
Severity string
|
||||
Passback chan<- struct{}
|
||||
@@ -115,7 +115,7 @@ type multiWriterHolder struct {
|
||||
|
||||
// ExtraFields is a map of key value pairs that can be added to a structured
|
||||
// log output.
|
||||
type ExtraFields map[Key]interface{}
|
||||
type ExtraFields map[Key]any
|
||||
|
||||
// Key is used for structured logging fields to ensure no collisions occur.
|
||||
// Unexported keys are default fields which cannot be overwritten.
|
||||
|
||||
@@ -6,10 +6,10 @@ import (
|
||||
)
|
||||
|
||||
// Infoln is a logging function that takes a sublogger and an arbitrary number
|
||||
// of interface{} arguments. This writes to configured io.Writer(s) as an
|
||||
// of any arguments. This writes to configured io.Writer(s) as an
|
||||
// information message using default formats for its operands. A new line is
|
||||
// automatically added to the output.
|
||||
func Infoln(sl *SubLogger, a ...interface{}) {
|
||||
func Infoln(sl *SubLogger, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -18,11 +18,11 @@ func Infoln(sl *SubLogger, a ...interface{}) {
|
||||
}
|
||||
|
||||
// InfolnWithFields is a logging function that takes a sublogger, additional
|
||||
// structured logging fields and an arbitrary number of interface{} arguments.
|
||||
// structured logging fields and an arbitrary number of any arguments.
|
||||
// This writes to configured io.Writer(s) as an information message using
|
||||
// default formats for its operands. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func InfolnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
func InfolnWithFields(sl *SubLogger, extra ExtraFields, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -35,7 +35,7 @@ func InfolnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
// with optional arguments. This writes to configured io.Writer(s) as an
|
||||
// information message which formats according to the format specifier.
|
||||
// A new line is automatically added to the output.
|
||||
func Infof(sl *SubLogger, format string, a ...interface{}) {
|
||||
func Infof(sl *SubLogger, format string, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -49,7 +49,7 @@ func Infof(sl *SubLogger, format string, a ...interface{}) {
|
||||
// formats according to the format specifier. A new line is automatically added
|
||||
// to the output. If structured logging is not enabled, the fields will be
|
||||
// ignored.
|
||||
func InfofWithFields(sl *SubLogger, extra ExtraFields, format string, a ...interface{}) { //nolint:goprintffuncname // False positive
|
||||
func InfofWithFields(sl *SubLogger, extra ExtraFields, format string, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -59,10 +59,10 @@ func InfofWithFields(sl *SubLogger, extra ExtraFields, format string, a ...inter
|
||||
}
|
||||
|
||||
// Debugln is a logging function that takes a sublogger and an arbitrary number
|
||||
// of interface{} arguments. This writes to configured io.Writer(s) as an
|
||||
// of any arguments. This writes to configured io.Writer(s) as an
|
||||
// debug message using default formats for its operands. A new line is
|
||||
// automatically added to the output.
|
||||
func Debugln(sl *SubLogger, v ...interface{}) {
|
||||
func Debugln(sl *SubLogger, v ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -71,11 +71,11 @@ func Debugln(sl *SubLogger, v ...interface{}) {
|
||||
}
|
||||
|
||||
// DebuglnWithFields is a logging function that takes a sublogger, additional
|
||||
// structured logging fields and an arbitrary number of interface{} arguments.
|
||||
// structured logging fields and an arbitrary number of any arguments.
|
||||
// This writes to configured io.Writer(s) as an debug message using default
|
||||
// formats for its operands. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func DebuglnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
func DebuglnWithFields(sl *SubLogger, extra ExtraFields, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -88,7 +88,7 @@ func DebuglnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
// with optional arguments. This writes to configured io.Writer(s) as an
|
||||
// debug message which formats according to the format specifier. A new line is
|
||||
// automatically added to the output.
|
||||
func Debugf(sl *SubLogger, data string, v ...interface{}) {
|
||||
func Debugf(sl *SubLogger, data string, v ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -101,7 +101,7 @@ func Debugf(sl *SubLogger, data string, v ...interface{}) {
|
||||
// This writes to configured io.Writer(s) as an debug message which formats
|
||||
// according to the format specifier. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func DebugfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...interface{}) { //nolint:goprintffuncname // False positive
|
||||
func DebugfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -111,10 +111,10 @@ func DebugfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...inte
|
||||
}
|
||||
|
||||
// Warnln is a logging function that takes a sublogger and an arbitrary number
|
||||
// of interface{} arguments. This writes to configured io.Writer(s) as an
|
||||
// of any arguments. This writes to configured io.Writer(s) as an
|
||||
// warning message using default formats for its operands. A new line is
|
||||
// automatically added to the output.
|
||||
func Warnln(sl *SubLogger, v ...interface{}) {
|
||||
func Warnln(sl *SubLogger, v ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -123,11 +123,11 @@ func Warnln(sl *SubLogger, v ...interface{}) {
|
||||
}
|
||||
|
||||
// WarnlnWithFields is a logging function that takes a sublogger, additional
|
||||
// structured logging fields and an arbitrary number of interface{} arguments.
|
||||
// structured logging fields and an arbitrary number of any arguments.
|
||||
// This writes to configured io.Writer(s) as an warning message using default
|
||||
// formats for its operands. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func WarnlnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
func WarnlnWithFields(sl *SubLogger, extra ExtraFields, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -140,7 +140,7 @@ func WarnlnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
// with optional arguments. This writes to configured io.Writer(s) as an
|
||||
// warning message which formats according to the format specifier. A new line
|
||||
// is automatically added to the output.
|
||||
func Warnf(sl *SubLogger, data string, v ...interface{}) {
|
||||
func Warnf(sl *SubLogger, data string, v ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -153,7 +153,7 @@ func Warnf(sl *SubLogger, data string, v ...interface{}) {
|
||||
// This writes to configured io.Writer(s) as an warning message which formats
|
||||
// according to the format specifier. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func WarnfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...interface{}) { //nolint:goprintffuncname // False positive
|
||||
func WarnfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -163,10 +163,10 @@ func WarnfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...inter
|
||||
}
|
||||
|
||||
// Errorln is a logging function that takes a sublogger and an arbitrary number
|
||||
// of interface{} arguments. This writes to configured io.Writer(s) as an
|
||||
// of any arguments. This writes to configured io.Writer(s) as an
|
||||
// error message using default formats for its operands. A new line is
|
||||
// automatically added to the output.
|
||||
func Errorln(sl *SubLogger, v ...interface{}) {
|
||||
func Errorln(sl *SubLogger, v ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -175,11 +175,11 @@ func Errorln(sl *SubLogger, v ...interface{}) {
|
||||
}
|
||||
|
||||
// ErrorlnWithFields is a logging function that takes a sublogger, additional
|
||||
// structured logging fields and an arbitrary number of interface{} arguments.
|
||||
// structured logging fields and an arbitrary number of any arguments.
|
||||
// This writes to configured io.Writer(s) as an error message using default
|
||||
// formats for its operands. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func ErrorlnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
func ErrorlnWithFields(sl *SubLogger, extra ExtraFields, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -192,7 +192,7 @@ func ErrorlnWithFields(sl *SubLogger, extra ExtraFields, a ...interface{}) {
|
||||
// with optional arguments. This writes to configured io.Writer(s) as an
|
||||
// error message which formats according to the format specifier. A new line
|
||||
// is automatically added to the output.
|
||||
func Errorf(sl *SubLogger, data string, v ...interface{}) {
|
||||
func Errorf(sl *SubLogger, data string, v ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
@@ -205,7 +205,7 @@ func Errorf(sl *SubLogger, data string, v ...interface{}) {
|
||||
// This writes to configured io.Writer(s) as an error message which formats
|
||||
// according to the format specifier. A new line is automatically added to the
|
||||
// output. If structured logging is not enabled, the fields will be ignored.
|
||||
func ErrorfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...interface{}) { //nolint:goprintffuncname // False positive
|
||||
func ErrorfWithFields(sl *SubLogger, extra ExtraFields, format string, a ...any) {
|
||||
mu.RLock()
|
||||
defer mu.RUnlock()
|
||||
if f := sl.getFields(); f != nil {
|
||||
|
||||
Reference in New Issue
Block a user