Esempio n. 1
0
// 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
}
Esempio n. 2
0
// KeyExists - Check whenever key exists within configuration manager instance
func (c *Config) KeyExists(key string) bool {
	return utils.KeyInSlice(key, c.Config)
}
Esempio n. 3
0
// ConfigManagerExists -
func ConfigManagerExists(manager string) bool {
	return utils.KeyInSlice(manager, ConfigManager)
}