package main

import (
	"flag"
	"fmt"
	"go.uber.org/zap"
	"go.uber.org/zap/zapcore"
)



// This func runs even before main()
func init() {

	config_file := flag.String("config", "/etc/ceph/ceph.conf", "placement of ceph config file")
	_keyring := flag.String("keyring", "/etc/ceph/ceph.client.admin.keyring", "placement of ceph keyring file")
	flag.Parse()

	params.Config = *config_file
	params.Keyring = *_keyring

	logger = loggerInit()
	logger.Info("Setting up logger is complete successfully")
	logger.Info("Registering prom metrics")
}

// Here I initialize logger and set some custom settings
func loggerInit() *zap.SugaredLogger {
	config := zap.NewDevelopmentConfig()
	config.EncoderConfig.TimeKey = "timestamp"
	config.EncoderConfig.EncodeTime = zapcore.ISO8601TimeEncoder
	logger, err := config.Build()
	if err != nil {
		panic(fmt.Sprintf("Logger set up failed: %v", err))
	}
	defer logger.Sync()
	return logger.Sugar()
}
