Files
gocryptotrader/log/logger_types.go
Ryan O'Hara-Reid a2381310da GCT: general updates across codebase (#699)
* orderbook: export orderbook nodes for external strategy inspection

* orderbook: Add in methods for locking and unlocking multiple books at the same time e.g. book1.LockWith(book2); defer book1.UnlockWith(book2)

* include waiting functionality for depth change alert

* backtester: add word.

* log: include logger changes to impl with downstream integration

* engine: reduce params for loading exchange

* assort: rm verbose in tests, change wording in ob, expose sync.waitgroup for ext. sync options

* ticker: reduce map look ups and contention when using RW mutex when there are over 80% writes adds find last function to get the latest rate

* engine/syncmanager: add in waitgroup for step over for external package calls

* cleaup

* engine: linter fix

* currency/fx: include all references to fiat currencies to default

* orderbook: Add in fields to Unsafe type for strategies to detect potential out of sync book operations

* syncmanager: changed config variable to display correct time

* ordermanager: Add time when none provided

* currency/manager: update getasset param to get enabled assets for minor optimizations

* ftx: use get all wallet balances for a better accounts breakdown

* orderbook: unlock in reverse order

* bithumb: fixes bug on market buy and sell orders

* bithumb: fix bug for nonce is also time window sensitive

* bithumb: get orders add required parameter

* bithumb: Add asset type to account struct

* currency: improve log output when checking currency and it fails

* bithumb: Add error return on incomplete pair

* ticker:unexport all service related methods

* ticker/currency: fixes

* orderbook: fix comment

* engine: revert variable name in LoadExchange method

* sync_manager: fix panic when enabling disabling manager

* engine: fix naming convention of exported function and comments

* engine: update comment

* orderbook: fix comment for unsafe type
2021-07-29 14:42:28 +10:00

106 lines
2.6 KiB
Go

package log
import (
"io"
"sync"
)
const (
timestampFormat = " 02/01/2006 15:04:05 "
spacer = " | "
// DefaultMaxFileSize for logger rotation file
DefaultMaxFileSize int64 = 100
)
var (
logger = &Logger{}
// FileLoggingConfiguredCorrectly flag set during config check if file logging meets requirements
FileLoggingConfiguredCorrectly bool
// GlobalLogConfig holds global configuration options for logger
GlobalLogConfig = &Config{}
// GlobalLogFile hold global configuration options for file logger
GlobalLogFile = &Rotate{}
eventPool = &sync.Pool{
New: func() interface{} {
return &Event{
data: make([]byte, 0, 80),
}
},
}
// LogPath system path to store log files in
LogPath string
// RWM read/write mutex for logger
RWM = &sync.RWMutex{}
)
// Config holds configuration settings loaded from bot config
type Config struct {
Enabled *bool `json:"enabled"`
SubLoggerConfig
LoggerFileConfig *loggerFileConfig `json:"fileSettings,omitempty"`
AdvancedSettings advancedSettings `json:"advancedSettings"`
SubLoggers []SubLoggerConfig `json:"subloggers,omitempty"`
}
type advancedSettings struct {
ShowLogSystemName *bool `json:"showLogSystemName"`
Spacer string `json:"spacer"`
TimeStampFormat string `json:"timeStampFormat"`
Headers headers `json:"headers"`
}
type headers struct {
Info string `json:"info"`
Warn string `json:"warn"`
Debug string `json:"debug"`
Error string `json:"error"`
}
// SubLoggerConfig holds sub logger configuration settings loaded from bot config
type SubLoggerConfig struct {
Name string `json:"name,omitempty"`
Level string `json:"level"`
Output string `json:"output"`
}
type loggerFileConfig struct {
FileName string `json:"filename,omitempty"`
Rotate *bool `json:"rotate,omitempty"`
MaxSize int64 `json:"maxsize,omitempty"`
}
// Logger each instance of logger settings
type Logger struct {
ShowLogSystemName bool
Timestamp string
InfoHeader, ErrorHeader, DebugHeader, WarnHeader string
Spacer string
}
// Levels flags for each sub logger type
type Levels struct {
Info, Debug, Warn, Error bool
}
// SubLogger defines a sub logger can be used externally for packages wanted to
// leverage GCT library logger features.
type SubLogger struct {
name string
Levels
output io.Writer
}
// Event holds the data sent to the log and which multiwriter to send to
type Event struct {
data []byte
output io.Writer
}
type multiWriter struct {
writers []io.Writer
mu sync.RWMutex
}