/*
 * Copyright 2020-present Open Networking Foundation
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

// Package config Common log initialization
package config

import (
	log "github.com/opencord/voltha-lib-go/v4/pkg/log"
)

// logger represents the log object
var logger log.CLogger

// Initlog initialise log package
func Initlog() log.CLogger {
	if logger != nil {
		return logger
	}
	// Setup this package so that it's log level can be modified at run time
	var err error

	coreFlags := NewCoreFlags()

	var logLevel log.LogLevel

	switch coreFlags.LogLevel {
	case LogLevelDebug:
		logLevel = log.DebugLevel
	case LogLevelInfo:
		logLevel = log.InfoLevel
	case LogLevelWarn:
		logLevel = log.WarnLevel
	case LogLevelError:
		logLevel = log.ErrorLevel
	default:
		logLevel = log.ErrorLevel
	}

	logger, err = log.RegisterPackage(log.JSON, logLevel, log.Fields{})
	if err != nil {
		panic(err)
	}
	return logger
}
