A simple logger written in Go, which is used to print errors, tips, etc. messages, was born while I was working on another project github.com/uynilo9/bento.
Btw it used to be in pkg/logger under github.com/uynilo9/bento originally. So far it still exists there but will no longer get updates there (if it's supposed to get any here lol).
- Install the module from GitHub url:
go get github.com/uynilo9/logger.go
- Import the module in your Go code:
import "github.com/uynilo9/logger.go"
a
(...any
): The detailed message(s) to be printed. You can pass any number of arguments of any type.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Detail("- Time: ", time, " - Code: " code)
_, err := logger.Detail("- Time: ", time, " - Code: " code)
if err != nil {
// ...
a
(...any
): The error message(s) to be printed. You can pass any number of arguments of any type.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Error("Unexpected character on line ", line, " column ", column)
_, err := logger.Error("Unexpected character on line ", line, " column ", column)
if err != nil {
// ...
a
(...any
): The fatal message(s) to be printed. You can pass any number of arguments of any type.
Warning
This function returns NOTHING because it directly EXITS after printing the message(s).
logger.Fatal("The required data \'", data, "\' was missing")
a
(...any
): The tip message(s) to be printed. You can pass any number of arguments of any type.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Tip("To get more info, visit ", url, "#", id)
_, err := logger.Tip("To get more info, visit ", url, "#", id)
if err != nil {
// ...
a
(...any
): The detailed message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Detailln("- Time: ", time, " - Code: " code)
_, err := logger.Detailln("- Time: ", time, " - Code: " code)
if err != nil {
// ...
a
(...any
): The error message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Error("Unexpected character on line ", line, " column ", column)
_, err := logger.Errorln("Unexpected character on line ", line, " column ", column)
if err != nil {
// ...
a
(...any
): The fatal message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
Warning
This function returns NOTHING because it directly EXITS after printing the message(s).
logger.Fatalln("The required data \'", data, "\' was missing")
a
(...any
): The tip message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Tipln("To get more info, visit ", url, "#", id)
_, err := logger.Tipln("To get more info, visit ", url, "#", id)
if err != nil {
// ...
format
(string
): The format string for the detailed message. It follows the same syntax asfmt.Printf
, allowing for formatted printing.a
(...any
): The values to be formatted and printed according to the format string.type.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Detailf("- Time: %g - Code: %d", time, code)
_, err := logger.Detailf("- Time: %g - Code: %d", time, code)
if err != nil {
// ...
format
(string
): The format string for the error message. It follows the same syntax asfmt.Printf
, allowing for formatted printing.a
(...any
): The values to be formatted and printed according to the format string.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Errorf("Unexpected character on line %d column %d", line, column)
_, err := logger.Errorf("Unexpected character on line %d column %d", line, column)
if err != nil {
// ...
format
(string
): The format string for the fatal message. It follows the same syntax asfmt.Printf
, allowing for formatted printing.a
(...any
): The values to be formatted and printed according to the format string.
Warning
This function returns NOTHING because it directly EXITS after printing the message(s).
logger.Fatalf("The required data \'%s\' was missing", data)
format
(string
): The format string for the tip message. It follows the same syntax asfmt.Printf
, allowing for formatted printing.a
(...any
): The values to be formatted and printed according to the format string.
n
(int
): The number of bytes written.err
(error
): Any write error encountered.
logger.Tipf("To get more info, visit %s#%d", url, id)
_, err := logger.Tipf("To get more info, visit %s#%d", url, id)
if err != nil {
// ...
0.0.1-dev.5
MIT License