storj/pkg/utils/logging.go
Yehor Butko 7ea075ce9e Unit Tests for logging.go added (#148)
* Unit Tests for logging.go added.

* Unit Tests for logging.go added part 2

* Unit tests added for Utils package
2018-07-19 15:41:29 -04:00

27 lines
582 B
Go

// Copyright (C) 2018 Storj Labs, Inc.
// See LICENSE for copying information.
package utils
import (
"strings"
"go.uber.org/zap"
)
var zapNewDevelopment = zap.NewDevelopment
var zapNewProduction = zap.NewProduction
var zapNewNop = zap.NewNop
// NewLogger takes an environment and a set of options for a logger
func NewLogger(e string, options ...zap.Option) (*zap.Logger, error) {
switch strings.ToLower(e) {
case "dev", "development":
return zapNewDevelopment(options...)
case "prod", "production":
return zapNewProduction(options...)
}
return zapNewNop(), nil
}