fix: remove import cycle
This commit is contained in:
parent
6e3e096be9
commit
b51f28ea64
|
@ -4,7 +4,6 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
_logger "git.lumeweb.com/LumeWeb/portal/logger"
|
|
||||||
"github.com/docker/go-units"
|
"github.com/docker/go-units"
|
||||||
"github.com/spf13/viper"
|
"github.com/spf13/viper"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -29,7 +28,7 @@ type Manager struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewManager() (*Manager, error) {
|
func NewManager() (*Manager, error) {
|
||||||
v, err := newConfig(nil)
|
v, err := newConfig()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -133,10 +132,8 @@ func (m *Manager) Save() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func newConfig(logger *zap.Logger) (*viper.Viper, error) {
|
func newConfig() (*viper.Viper, error) {
|
||||||
if logger == nil {
|
logger := newFallbackLogger()
|
||||||
logger = _logger.NewFallbackLogger()
|
|
||||||
}
|
|
||||||
|
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
viper.SetConfigType("yaml")
|
viper.SetConfigType("yaml")
|
||||||
|
@ -166,3 +163,8 @@ func newConfig(logger *zap.Logger) (*viper.Viper, error) {
|
||||||
|
|
||||||
return viper.GetViper(), nil
|
return viper.GetViper(), nil
|
||||||
}
|
}
|
||||||
|
func newFallbackLogger() *zap.Logger {
|
||||||
|
l, _ := zap.NewDevelopment()
|
||||||
|
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
|
@ -9,12 +9,6 @@ import (
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewFallbackLogger() *zap.Logger {
|
|
||||||
logger, _ := zap.NewDevelopment()
|
|
||||||
|
|
||||||
return logger
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewLogger(cm *config.Manager) (*zap.Logger, *zap.AtomicLevel) {
|
func NewLogger(cm *config.Manager) (*zap.Logger, *zap.AtomicLevel) {
|
||||||
|
|
||||||
// Create a new atomic level
|
// Create a new atomic level
|
||||||
|
|
Loading…
Reference in New Issue