mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 17:24:04 +00:00
916ec63af6
This is a new revision of the discovery server. Relevant changes and non-changes: - Protocol towards clients is unchanged. - Recommended large scale design is still to be deployed nehind nginx (I tested, and it's still a lot faster at terminating TLS). - Database backend is leveldb again, only. It scales enough, is easy to setup, and we don't need any backend to take care of. - Server supports replication. This is a simple TCP channel - protect it with a firewall when deploying over the internet. (We deploy this within the same datacenter, and with firewall.) Any incoming client announces are sent over the replication channel(s) to other peer discosrvs. Incoming replication changes are applied to the database as if they came from clients, but without the TLS/certificate overhead. - Metrics are exposed using the prometheus library, when enabled. - The database values and replication protocol is protobuf, because JSON was quite CPU intensive when I tried that and benchmarked it. - The "Retry-After" value for failed lookups gets slowly increased from a default of 120 seconds, by 5 seconds for each failed lookup, independently by each discosrv. This lowers the query load over time for clients that are never seen. The Retry-After maxes out at 3600 after a couple of weeks of this increase. The number of failed lookups is stored in the database, now and then (avoiding making each lookup a database put). All in all this means clients can be pointed towards a cluster using just multiple A / AAAA records to gain both load sharing and redundancy (if one is down, clients will talk to the remaining ones). GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4648
194 lines
4.8 KiB
Go
194 lines
4.8 KiB
Go
package logrus
|
|
|
|
import (
|
|
"io"
|
|
)
|
|
|
|
var (
|
|
// std is the name of the standard logger in stdlib `log`
|
|
std = New()
|
|
)
|
|
|
|
func StandardLogger() *Logger {
|
|
return std
|
|
}
|
|
|
|
// SetOutput sets the standard logger output.
|
|
func SetOutput(out io.Writer) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Out = out
|
|
}
|
|
|
|
// SetFormatter sets the standard logger formatter.
|
|
func SetFormatter(formatter Formatter) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Formatter = formatter
|
|
}
|
|
|
|
// SetLevel sets the standard logger level.
|
|
func SetLevel(level Level) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.SetLevel(level)
|
|
}
|
|
|
|
// GetLevel returns the standard logger level.
|
|
func GetLevel() Level {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
return std.level()
|
|
}
|
|
|
|
// AddHook adds a hook to the standard logger hooks.
|
|
func AddHook(hook Hook) {
|
|
std.mu.Lock()
|
|
defer std.mu.Unlock()
|
|
std.Hooks.Add(hook)
|
|
}
|
|
|
|
// WithError creates an entry from the standard logger and adds an error to it, using the value defined in ErrorKey as key.
|
|
func WithError(err error) *Entry {
|
|
return std.WithField(ErrorKey, err)
|
|
}
|
|
|
|
// WithField creates an entry from the standard logger and adds a field to
|
|
// it. If you want multiple fields, use `WithFields`.
|
|
//
|
|
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
|
// or Panic on the Entry it returns.
|
|
func WithField(key string, value interface{}) *Entry {
|
|
return std.WithField(key, value)
|
|
}
|
|
|
|
// WithFields creates an entry from the standard logger and adds multiple
|
|
// fields to it. This is simply a helper for `WithField`, invoking it
|
|
// once for each field.
|
|
//
|
|
// Note that it doesn't log until you call Debug, Print, Info, Warn, Fatal
|
|
// or Panic on the Entry it returns.
|
|
func WithFields(fields Fields) *Entry {
|
|
return std.WithFields(fields)
|
|
}
|
|
|
|
// Debug logs a message at level Debug on the standard logger.
|
|
func Debug(args ...interface{}) {
|
|
std.Debug(args...)
|
|
}
|
|
|
|
// Print logs a message at level Info on the standard logger.
|
|
func Print(args ...interface{}) {
|
|
std.Print(args...)
|
|
}
|
|
|
|
// Info logs a message at level Info on the standard logger.
|
|
func Info(args ...interface{}) {
|
|
std.Info(args...)
|
|
}
|
|
|
|
// Warn logs a message at level Warn on the standard logger.
|
|
func Warn(args ...interface{}) {
|
|
std.Warn(args...)
|
|
}
|
|
|
|
// Warning logs a message at level Warn on the standard logger.
|
|
func Warning(args ...interface{}) {
|
|
std.Warning(args...)
|
|
}
|
|
|
|
// Error logs a message at level Error on the standard logger.
|
|
func Error(args ...interface{}) {
|
|
std.Error(args...)
|
|
}
|
|
|
|
// Panic logs a message at level Panic on the standard logger.
|
|
func Panic(args ...interface{}) {
|
|
std.Panic(args...)
|
|
}
|
|
|
|
// Fatal logs a message at level Fatal on the standard logger.
|
|
func Fatal(args ...interface{}) {
|
|
std.Fatal(args...)
|
|
}
|
|
|
|
// Debugf logs a message at level Debug on the standard logger.
|
|
func Debugf(format string, args ...interface{}) {
|
|
std.Debugf(format, args...)
|
|
}
|
|
|
|
// Printf logs a message at level Info on the standard logger.
|
|
func Printf(format string, args ...interface{}) {
|
|
std.Printf(format, args...)
|
|
}
|
|
|
|
// Infof logs a message at level Info on the standard logger.
|
|
func Infof(format string, args ...interface{}) {
|
|
std.Infof(format, args...)
|
|
}
|
|
|
|
// Warnf logs a message at level Warn on the standard logger.
|
|
func Warnf(format string, args ...interface{}) {
|
|
std.Warnf(format, args...)
|
|
}
|
|
|
|
// Warningf logs a message at level Warn on the standard logger.
|
|
func Warningf(format string, args ...interface{}) {
|
|
std.Warningf(format, args...)
|
|
}
|
|
|
|
// Errorf logs a message at level Error on the standard logger.
|
|
func Errorf(format string, args ...interface{}) {
|
|
std.Errorf(format, args...)
|
|
}
|
|
|
|
// Panicf logs a message at level Panic on the standard logger.
|
|
func Panicf(format string, args ...interface{}) {
|
|
std.Panicf(format, args...)
|
|
}
|
|
|
|
// Fatalf logs a message at level Fatal on the standard logger.
|
|
func Fatalf(format string, args ...interface{}) {
|
|
std.Fatalf(format, args...)
|
|
}
|
|
|
|
// Debugln logs a message at level Debug on the standard logger.
|
|
func Debugln(args ...interface{}) {
|
|
std.Debugln(args...)
|
|
}
|
|
|
|
// Println logs a message at level Info on the standard logger.
|
|
func Println(args ...interface{}) {
|
|
std.Println(args...)
|
|
}
|
|
|
|
// Infoln logs a message at level Info on the standard logger.
|
|
func Infoln(args ...interface{}) {
|
|
std.Infoln(args...)
|
|
}
|
|
|
|
// Warnln logs a message at level Warn on the standard logger.
|
|
func Warnln(args ...interface{}) {
|
|
std.Warnln(args...)
|
|
}
|
|
|
|
// Warningln logs a message at level Warn on the standard logger.
|
|
func Warningln(args ...interface{}) {
|
|
std.Warningln(args...)
|
|
}
|
|
|
|
// Errorln logs a message at level Error on the standard logger.
|
|
func Errorln(args ...interface{}) {
|
|
std.Errorln(args...)
|
|
}
|
|
|
|
// Panicln logs a message at level Panic on the standard logger.
|
|
func Panicln(args ...interface{}) {
|
|
std.Panicln(args...)
|
|
}
|
|
|
|
// Fatalln logs a message at level Fatal on the standard logger.
|
|
func Fatalln(args ...interface{}) {
|
|
std.Fatalln(args...)
|
|
}
|