Documentation ¶
Index ¶
- Variables
- func CollectAndUploadData(dataDir string, bundleFilename string, targetFolder string) <-chan error
- func EnableTelemetry(cfg TelemetryConfig, l *logger) (err error)
- func Init()
- func SanitizeTelemetryString(input string, maxParts int) string
- func TelemetryOverride(env string, telemetryConfig *TelemetryConfig) bool
- func UsageLogThread(ctx context.Context, log Logger, period time.Duration, wg *sync.WaitGroup)
- type CyclicFileWriter
- type Fields
- type Level
- type Logger
- type MarshalingTelemetryConfig
- type TelemetryConfig
- func EnsureTelemetryConfig(dataDir *string, genesisID string) (TelemetryConfig, error)
- func EnsureTelemetryConfigCreated(dataDir *string, genesisID string) (TelemetryConfig, bool, error)
- func LoadTelemetryConfig(configPath string) (TelemetryConfig, error)
- func ReadTelemetryConfigOrDefault(dataDir string, genesisID string) (cfg TelemetryConfig, err error)
- type TelemetryOperation
- type TestLogWriter
Constants ¶
This section is empty.
Variables ¶
var TelemetryConfigFilename = "logging.config"
TelemetryConfigFilename default file name for telemetry config "logging.config"
Functions ¶
func CollectAndUploadData ¶
CollectAndUploadData combines all of the data files that we want packaged up and uploaded for analysis and uploads the tarball to S3. dataDir: the node's data directory containing the files of interest bundleFilename: the name of the resulting tarball on S3 targetFolder: the subfolder in the s3 bucket to store the file
func EnableTelemetry ¶
func EnableTelemetry(cfg TelemetryConfig, l *logger) (err error)
EnableTelemetry configures and enables telemetry based on the config provided
func SanitizeTelemetryString ¶
SanitizeTelemetryString applies sanitization rules and returns the sanitized string.
func TelemetryOverride ¶
func TelemetryOverride(env string, telemetryConfig *TelemetryConfig) bool
TelemetryOverride Determines whether an override value is set and what it's value is. The first return value is whether an override variable is found, if it is, the second is the override value.
Types ¶
type CyclicFileWriter ¶
type CyclicFileWriter struct {
// contains filtered or unexported fields
}
CyclicFileWriter implements the io.Writer interface and wraps an underlying file. It ensures that the file never grows over a limit.
func MakeCyclicFileWriter ¶
func MakeCyclicFileWriter(liveLogFilePath string, archiveFilePath string, sizeLimitBytes uint64, maxLogAge time.Duration) *CyclicFileWriter
MakeCyclicFileWriter returns a writer that wraps a file to ensure it never grows too large
type Level ¶
type Level uint32
Level refers to the log logging level
const ( // Panic Level level, highest level of severity. Logs and then calls panic with the // message passed to Debug, Info, ... Panic Level = iota // Fatal Level level. Logs and then calls `os.Exit(1)`. It will exit even if the // logging level is set to Panic. Fatal // Error Level level. Used for errors that should definitely be noted. // Commonly used for hooks to send errors to an error tracking service. Error // Warn Level level. Non-critical entries that deserve eyes. Warn // Info Level level. General operational entries about what's going on inside the // application. Info // Debug Level level. Usually only enabled when debugging. Very verbose logging. Debug )
type Logger ¶
type Logger interface { // Debug logs a message at level Debug. Debug(...interface{}) Debugln(...interface{}) Debugf(string, ...interface{}) // Info logs a message at level Info. Info(...interface{}) Infoln(...interface{}) Infof(string, ...interface{}) // Warn logs a message at level Warn. Warn(...interface{}) Warnln(...interface{}) Warnf(string, ...interface{}) // Error logs a message at level Error. Error(...interface{}) Errorln(...interface{}) Errorf(string, ...interface{}) // Fatal logs a message at level Fatal. Fatal(...interface{}) Fatalln(...interface{}) Fatalf(string, ...interface{}) // Panic logs a message at level Panic. Panic(...interface{}) Panicln(...interface{}) Panicf(string, ...interface{}) // Add one key-value to log With(key string, value interface{}) Logger // WithFields logs a message with specific fields WithFields(Fields) Logger // Set the logging version (Info by default) SetLevel(Level) // Sets the output target SetOutput(io.Writer) // Sets the logger to JSON Format SetJSONFormatter() IsLevelEnabled(level Level) bool // Adds a hook to the logger AddHook(hook logrus.Hook) EnableTelemetry(cfg TelemetryConfig) error UpdateTelemetryURI(uri string) error GetTelemetryEnabled() bool GetTelemetryUploadingEnabled() bool Metrics(category telemetryspec.Category, metrics telemetryspec.MetricDetails, details interface{}) Event(category telemetryspec.Category, identifier telemetryspec.Event) EventWithDetails(category telemetryspec.Category, identifier telemetryspec.Event, details interface{}) StartOperation(category telemetryspec.Category, identifier telemetryspec.Operation) TelemetryOperation GetTelemetrySession() string GetTelemetryHostName() string GetInstanceName() string GetTelemetryURI() string CloseTelemetry() // contains filtered or unexported methods }
Logger is the interface for loggers.
func TestingLog ¶
TestingLog is a test-only convenience function to configure logging for testing
type MarshalingTelemetryConfig ¶
type MarshalingTelemetryConfig struct { TelemetryConfig MinLogLevel uint32 ReportHistoryLevel uint32 }
MarshalingTelemetryConfig is used for json serialization of the TelemetryConfig so that we could replace the MinLogLevel/ReportHistoryLevel with our own types.
type TelemetryConfig ¶
type TelemetryConfig struct { Enable bool SendToLog bool URI string Name string GUID string MinLogLevel logrus.Level `json:"-"` // these are the logrus.Level, but we can't use it directly since on logrus version 1.4.2 they added ReportHistoryLevel logrus.Level `json:"-"` // text marshalers which breaks our backward compatibility. FilePath string // Path to file on disk, if any ChainID string `json:"-"` SessionGUID string `json:"-"` UserName string Password string }
TelemetryConfig represents the configuration of Telemetry logging
func EnsureTelemetryConfig ¶
func EnsureTelemetryConfig(dataDir *string, genesisID string) (TelemetryConfig, error)
EnsureTelemetryConfig creates a new TelemetryConfig structure with a generated GUID and the appropriate Telemetry endpoint Err will be non-nil if the file doesn't exist, or if error loading. Cfg will always be valid.
func EnsureTelemetryConfigCreated ¶
func EnsureTelemetryConfigCreated(dataDir *string, genesisID string) (TelemetryConfig, bool, error)
EnsureTelemetryConfigCreated is the same as EnsureTelemetryConfig but it also returns a bool indicating whether EnsureTelemetryConfig had to create the config.
func LoadTelemetryConfig ¶
func LoadTelemetryConfig(configPath string) (TelemetryConfig, error)
LoadTelemetryConfig loads the TelemetryConfig from the config file
func ReadTelemetryConfigOrDefault ¶
func ReadTelemetryConfigOrDefault(dataDir string, genesisID string) (cfg TelemetryConfig, err error)
ReadTelemetryConfigOrDefault reads telemetry config from file or defaults if no config file found.
func (TelemetryConfig) Save ¶
func (cfg TelemetryConfig) Save(configPath string) error
Save saves the TelemetryConfig to the config file
type TelemetryOperation ¶
type TelemetryOperation struct {
// contains filtered or unexported fields
}
TelemetryOperation wraps the context for an ongoing telemetry.StartOperation call
func (*TelemetryOperation) Stop ¶
func (op *TelemetryOperation) Stop(l logger, details interface{})
Stop is called to report the completion of an operation started by logger.StartOperation
type TestLogWriter ¶
TestLogWriter is an io.Writer that wraps a testing.T (or a testing.B) -- anything written to it gets logged with t.Log(...) Being an io.Writer lets us pass it to Logger.SetOutput() in testing code -- this way if we want we can use Go's built-in testing log instead of making a new base.log file for each test. As a bonus, the detailed logs produced in a Travis test are now easily accessible and are printed if and only if that particular ttest fails.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package logspec specifies the data format of event log statements.
|
Package logspec specifies the data format of event log statements. |