mirror of
https://github.com/strukturag/nextcloud-spreed-signaling
synced 2024-05-04 06:43:11 +02:00
82 lines
2.1 KiB
Go
82 lines
2.1 KiB
Go
/**
|
|
* Standalone signaling server for the Nextcloud Spreed app.
|
|
* Copyright (C) 2022 struktur AG
|
|
*
|
|
* @author Joachim Bauch <bauch@struktur.de>
|
|
*
|
|
* @license GNU AGPL version 3 or any later version
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
package signaling
|
|
|
|
import (
|
|
"go.uber.org/zap"
|
|
"go.uber.org/zap/zapcore"
|
|
)
|
|
|
|
type Logger interface {
|
|
Debug(args ...interface{})
|
|
Debugf(template string, args ...interface{})
|
|
Debugw(msg string, args ...interface{})
|
|
|
|
Error(args ...interface{})
|
|
Errorf(template string, args ...interface{})
|
|
Errorw(msg string, args ...interface{})
|
|
|
|
Fatal(args ...interface{})
|
|
Fatalf(template string, args ...interface{})
|
|
Fatalw(msg string, args ...interface{})
|
|
|
|
Info(args ...interface{})
|
|
Infof(template string, args ...interface{})
|
|
Infow(msg string, args ...interface{})
|
|
|
|
Warn(args ...interface{})
|
|
Warnf(template string, args ...interface{})
|
|
Warnw(msg string, args ...interface{})
|
|
|
|
With(args ...interface{}) Logger
|
|
|
|
Sync() error
|
|
}
|
|
|
|
type logger struct {
|
|
*zap.SugaredLogger
|
|
}
|
|
|
|
func (l *logger) With(args ...interface{}) Logger {
|
|
sugar := l.SugaredLogger.With(args...)
|
|
return WrapSugaredLogger(sugar)
|
|
}
|
|
|
|
func NewLogger() (Logger, error) {
|
|
cfg := zap.NewProductionConfig()
|
|
cfg.EncoderConfig.TimeKey = "timestamp"
|
|
cfg.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
|
|
l, err := cfg.Build()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
sugar := l.Sugar()
|
|
return WrapSugaredLogger(sugar), nil
|
|
}
|
|
|
|
func WrapSugaredLogger(sugar *zap.SugaredLogger) Logger {
|
|
return &logger{
|
|
sugar,
|
|
}
|
|
}
|