Skip to content

Commit

Permalink
Added error check and made golint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffAlyanak committed Feb 22, 2020
1 parent 8c187d6 commit dcedddf
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions logger/logger.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,37 @@
package logger

import (
"fmt"
"log"
"os"
"sync"
)

type logger struct {
// Logger struct bundles log.Logger and filename
type Logger struct {
filename string
*log.Logger
}

var lg *logger
var lg *Logger
var once sync.Once

func Get() *logger {
// Get Returns a Logger
func Get() *Logger { // TODO: Add user configurable log directory
once.Do(func() {
lg = makeLogger("godaddy-check.log")
lg = makeLogger("check_godaddy.log")
})
return lg
}

func makeLogger(fname string) *logger {
file, _ := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
func makeLogger(fname string) *Logger {
file, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0777)
if err != nil {
fmt.Println("Could not open log file at: ", fname)
os.Exit(3)
}

return &logger{
return &Logger{
filename: fname,
Logger: log.New(file, "", log.Ldate|log.Ltime),
}
Expand Down

0 comments on commit dcedddf

Please sign in to comment.