2018-05-16 19:47:59 +01:00
|
|
|
// Copyright (C) 2018 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package utils
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"go.uber.org/zap"
|
|
|
|
)
|
|
|
|
|
2018-07-19 20:41:29 +01:00
|
|
|
var zapNewDevelopment = zap.NewDevelopment
|
|
|
|
var zapNewProduction = zap.NewProduction
|
|
|
|
var zapNewNop = zap.NewNop
|
|
|
|
|
2018-05-16 19:47:59 +01:00
|
|
|
// 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":
|
2018-07-19 20:41:29 +01:00
|
|
|
return zapNewDevelopment(options...)
|
2018-05-16 19:47:59 +01:00
|
|
|
case "prod", "production":
|
2018-07-19 20:41:29 +01:00
|
|
|
return zapNewProduction(options...)
|
2018-05-16 19:47:59 +01:00
|
|
|
}
|
|
|
|
|
2018-07-19 20:41:29 +01:00
|
|
|
return zapNewNop(), nil
|
2018-05-16 19:47:59 +01:00
|
|
|
}
|