Merge pull request #151 from yunginnanet/development
This commit is contained in:
commit
edc9ca9d26
|
@ -22,7 +22,7 @@ jobs:
|
|||
export PATH=$PATH:$(go env GOPATH)/bin
|
||||
go install github.com/securego/gosec/v2/cmd/gosec@latest
|
||||
gosec ./...
|
||||
- name: go test -v ./...
|
||||
run: go test -v ./...
|
||||
- name: go test -race -v ./...
|
||||
run: go test -race -v ./...
|
||||
- name: go build -v ./...
|
||||
run: go build -v ./...
|
||||
|
|
|
@ -50,7 +50,7 @@ func main() {
|
|||
signal.Notify(stopChan, syscall.SIGINT, syscall.SIGTERM)
|
||||
|
||||
go func() {
|
||||
log.Error().Err(http.Serve()).Msg("HTTP error")
|
||||
log.Fatal().Err(http.Serve()).Msg("HTTP error")
|
||||
}()
|
||||
|
||||
<-stopChan // wait for SIGINT
|
||||
|
|
|
@ -18,9 +18,7 @@ var (
|
|||
logger zerolog.Logger
|
||||
)
|
||||
|
||||
// StartLogger instantiates an instance of our zerolog loggger so we can hook it in our main package.
|
||||
// While this does return a logger, it should not be used for additional retrievals of the logger. Use GetLogger()
|
||||
func StartLogger(pretty bool, targets ...io.Writer) zerolog.Logger {
|
||||
func prepLogDir() {
|
||||
logDir = snek.GetString("logger.directory")
|
||||
if !strings.HasSuffix(logDir, "/") {
|
||||
logDir += "/"
|
||||
|
@ -29,7 +27,11 @@ func StartLogger(pretty bool, targets ...io.Writer) zerolog.Logger {
|
|||
println("cannot create log directory: " + logDir + "(" + err.Error() + ")")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
// StartLogger instantiates an instance of our zerolog loggger so we can hook it in our main package.
|
||||
// While this does return a logger, it should not be used for additional retrievals of the logger. Use GetLogger().
|
||||
func StartLogger(pretty bool, targets ...io.Writer) zerolog.Logger {
|
||||
logFileName := "HellPot"
|
||||
|
||||
if snek.GetBool("logger.use_date_filename") {
|
||||
|
@ -44,9 +46,10 @@ func StartLogger(pretty bool, targets ...io.Writer) zerolog.Logger {
|
|||
case len(targets) > 0:
|
||||
logFile = io.MultiWriter(targets...)
|
||||
default:
|
||||
prepLogDir()
|
||||
CurrentLogFile = path.Join(logDir, logFileName+".log")
|
||||
|
||||
logFile, err = os.OpenFile(CurrentLogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o666) // #nosec G304 G302
|
||||
//nolint:lll
|
||||
logFile, err = os.OpenFile(CurrentLogFile, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0o666) // #nosec G304 G302 -- we are not using user input to create the file
|
||||
if err != nil {
|
||||
println("cannot create log file: " + err.Error())
|
||||
os.Exit(1)
|
||||
|
@ -63,7 +66,7 @@ func StartLogger(pretty bool, targets ...io.Writer) zerolog.Logger {
|
|||
return logger
|
||||
}
|
||||
|
||||
// GetLogger retrieves our global logger object
|
||||
// GetLogger retrieves our global logger object.
|
||||
func GetLogger() *zerolog.Logger {
|
||||
// future logic here
|
||||
return &logger
|
||||
|
|
Loading…
Reference in New Issue