コード例 #1
0
ファイル: logging.go プロジェクト: powerunit-io/platform
// New -
func New(conf map[string]interface{}) *Logger {
	logger := Logger{}

	forceColors := FormatterForceColors
	timestampFormat := FormatterTimestampFormat

	if utils.KeyInSlice("formatter_force_colors", conf) {
		forceColors = conf["formatter_force_colors"].(bool)
	}

	if utils.KeyInSlice("formatter_timestamp_format", conf) {
		timestampFormat = conf["formatter_timestamp_format"].(string)
	}

	logger.SetFormatter(&logrus.TextFormatter{
		ForceColors:     forceColors,
		TimestampFormat: timestampFormat,
	})

	if utils.KeyInSlice("output", conf) {
		logger.SetOutput(conf["output"].(io.Writer))
	}

	if utils.KeyInSlice("level", conf) {
		logger.SetLevel(conf["level"].(string))
	}

	return &logger
}
コード例 #2
0
ファイル: config.go プロジェクト: powerunit-io/platform
// KeyExists - Check whenever key exists within configuration manager instance
func (c *Config) KeyExists(key string) bool {
	return utils.KeyInSlice(key, c.Config)
}
コード例 #3
0
ファイル: manager.go プロジェクト: powerunit-io/platform
// ConfigManagerExists -
func ConfigManagerExists(manager string) bool {
	return utils.KeyInSlice(manager, ConfigManager)
}