-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
179 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module github.com/bb4L/rpi-radio-alarm-go-library | ||
|
||
go 1.15 | ||
go 1.16 | ||
|
||
require github.com/joho/godotenv v1.3.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
// Package logging contains some logging utils | ||
package logging | ||
|
||
import ( | ||
"log" | ||
"os" | ||
"sync" | ||
) | ||
|
||
const commonPrefix = "[rpi-radio-alarm-library]\t" | ||
|
||
var ( | ||
// InfoLogger logging infos | ||
InfoLogger *log.Logger | ||
|
||
// ErrorLogger logging errors | ||
ErrorLogger *log.Logger | ||
|
||
// FatalLogger logging fatal | ||
FatalLogger *log.Logger | ||
|
||
once sync.Once | ||
) | ||
|
||
// Get the InfoLogger | ||
func GetInfoLogger() *log.Logger { | ||
once.Do(func() { | ||
InfoLogger = log.New(os.Stderr, commonPrefix+"INFO: ", log.Ldate|log.Ltime|log.Lmsgprefix) | ||
}) | ||
return InfoLogger | ||
} | ||
|
||
// Get the ErrorLogger | ||
func GetErrorLogger() *log.Logger { | ||
once.Do(func() { | ||
ErrorLogger = log.New(os.Stderr, commonPrefix+"ERROR: ", log.Ldate|log.Ltime|log.Lmsgprefix) | ||
}) | ||
return ErrorLogger | ||
} | ||
|
||
// Get the FatalLogger | ||
func GetFatalLogger() *log.Logger { | ||
once.Do(func() { | ||
FatalLogger = log.New(os.Stderr, commonPrefix+"FATAL: ", log.Ldate|log.Ltime|log.Lmsgprefix) | ||
}) | ||
return FatalLogger | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.