github.com/vchain-us/vcn@v0.9.11-0.20210921212052-a2484d23c0b3/internal/logs/log.go (about) 1 /* 2 * Copyright (c) 2018-2020 vChain, Inc. All Rights Reserved. 3 * This software is released under GPL3. 4 * The full license information can be found under: 5 * https://www.gnu.org/licenses/gpl-3.0.en.html 6 * 7 */ 8 package logs 9 10 import ( 11 "os" 12 13 "github.com/sirupsen/logrus" 14 ) 15 16 // LOG is the global instance of logrus.Logger 17 var LOG = logrus.New() 18 19 func init() { 20 LOG.ExitFunc = func(code int) {} // prevent from exiting immediately on fatal 21 ll := os.Getenv("LOG_LEVEL") 22 switch ll { 23 case "TRACE": 24 LOG.SetLevel(logrus.TraceLevel) 25 case "DEBUG": 26 LOG.SetLevel(logrus.DebugLevel) 27 case "INFO": 28 LOG.SetLevel(logrus.InfoLevel) 29 case "WARN": 30 LOG.SetLevel(logrus.WarnLevel) 31 case "ERROR": 32 LOG.SetLevel(logrus.ErrorLevel) 33 case "FATAL": 34 LOG.SetLevel(logrus.FatalLevel) 35 case "PANIC": 36 LOG.SetLevel(logrus.PanicLevel) 37 default: 38 LOG.SetLevel(logrus.FatalLevel) 39 } 40 }