logger

package module
v0.0.1-dev.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2024 License: MIT Imports: 3 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

🌴 - A simple logger for Go

✨ Intro

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).

📦 Installation

  1. Install the module from GitHub url:
go get github.com/uynilo9/logger.go
  1. Import the module in your Go code:
import "github.com/uynilo9/logger.go"

⚙️ Functionality

1. logger.Detail(a ...any)
(a) Argument(s):
  • a (...any): The detailed message(s) to be printed. You can pass any number of arguments of any type.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Detail("- Time: ", time, " - Code: " code)

_, err := logger.Detail("- Time: ", time, " - Code: " code)
if err != nil {
    // ...
2. logger.Error(a ...any)
(a) Argument(s):
  • a (...any): The error message(s) to be printed. You can pass any number of arguments of any type.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Error("Unexpected character on line ", line, " column ", column)

_, err := logger.Error("Unexpected character on line ", line, " column ", column)
if err != nil {
    // ...
3. logger.Fatal(a ...any)
(a) Argument(s):
  • a (...any): The fatal message(s) to be printed. You can pass any number of arguments of any type.
(b) Return:

[!WARNING] This function returns NOTHING because it directly EXITS after printing the message(s).

(c) Example:
logger.Fatal("The required data \'", data, "\' was missing")
4. logger.Tip(a ...any)
(a) Argument(s):
  • a (...any): The tip message(s) to be printed. You can pass any number of arguments of any type.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Tip("To get more info, visit ", url, "#", id)

_, err := logger.Tip("To get more info, visit ", url, "#", id)
if err != nil {
    // ...
5. logger.Warn(a ...any)
(a) Argument(s):
  • a (...any): The warning message(s) to be printed. You can pass any number of arguments of any type.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Warn("New version ", version, " has been released, please update")

_, err := logger.Warn("New version ", version, " has been released, please update")
if err != nil {
    // ...
6. logger.Detailln(a ...any)
(a) Argument(s):
  • a (...any): The detailed message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Detailln("- Time: ", time, " - Code: " code)

_, err := logger.Detailln("- Time: ", time, " - Code: " code)
if err != nil {
    // ...
7. logger.Errorln(a ...any)
(a) Argument(s):
  • a (...any): The error message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Error("Unexpected character on line ", line, " column ", column)

_, err := logger.Errorln("Unexpected character on line ", line, " column ", column)
if err != nil {
    // ...
8. logger.Fatalln(a ...any)
(a) Argument(s):
  • a (...any): The fatal message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
(b) Return:

[!WARNING] This function returns NOTHING because it directly EXITS after printing the message(s).

(c) Example:
logger.Fatalln("The required data \'", data, "\' was missing")
9. logger.Tipln(a ...any)
(a) Argument(s):
  • a (...any): The tip message(s) to be printed. You can pass any number of arguments of any type. A newline is always appended.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Tipln("To get more info, visit ", url, "#", id)

_, err := logger.Tipln("To get more info, visit ", url, "#", id)
if err != nil {
    // ...
10. logger.Warnln(a ...any)
(a) Argument(s):
  • a (...any): The warning message(s) to be printed. You can pass any number of arguments of any type.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Warnln("New version ", version, " has been released, please update")

_, err := logger.Warnln("New version ", version, " has been released, please update")
if err != nil {
    // ...
11. logger.Detailf(format string, a ...any)
(a) Argument(s):
  • format (string): The format string for the detailed message. It follows the same syntax as fmt.Printf, allowing for formatted printing.
  • a (...any): The values to be formatted and printed according to the format string.type.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Detailf("- Time: %g - Code: %d", time, code)

_, err := logger.Detailf("- Time: %g - Code: %d", time, code)
if err != nil {
    // ...
12. logger.Errorf(format string, a ...any)
(a) Argument(s):
  • format (string): The format string for the error message. It follows the same syntax as fmt.Printf, allowing for formatted printing.
  • a (...any): The values to be formatted and printed according to the format string.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
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 {
    // ...
13. logger.Fatalf(format string, a ...any)
(a) Argument(s):
  • format (string): The format string for the fatal message. It follows the same syntax as fmt.Printf, allowing for formatted printing.
  • a (...any): The values to be formatted and printed according to the format string.
(b) Return:

[!WARNING] This function returns NOTHING because it directly EXITS after printing the message(s).

(c) Example:
logger.Fatalf("The required data \'%s\' was missing", data)
14. logger.Tipf(format string, a ...any)
(a) Argument(s):
  • format (string): The format string for the tip message. It follows the same syntax as fmt.Printf, allowing for formatted printing.
  • a (...any): The values to be formatted and printed according to the format string.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
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 {
    // ...
15. logger.Warnf(format string, a ...any)
(a) Argument(s):
  • format (string): The format string for the warning message. It follows the same syntax as fmt.Printf, allowing for formatted printing.
  • a (...any): The values to be formatted and printed according to the format string.
(b) Return:
  • n (int): The number of bytes written.
  • err (error): Any write error encountered.
(c) Example:
logger.Warnf("New version %s has been released, please update", version)

_, err := logger.Warnf("New version %s has been released, please update", version)
if err != nil {
    // ...

🔖 Version

0.0.1-dev.6

📜 License

MIT License

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Detail

func Detail(a ...any) (int, error)
Example
logger.Detail("- Time: ", time, " - Code: ", code)
Output:
DETAIL
- Time: 10.5 - Code: 213

func Detailf

func Detailf(format string, a ...any) (int, error)
Example
logger.Detailf("- Time: %g - Code: %d", time, code)
Output:
DETAIL
- Time: 10.5 - Code: 213

func Detailln

func Detailln(a ...any) (int, error)
Example
logger.Detailln("- Time: ", time, " - Code: ", code)
Output:
DETAIL
- Time: 10.5 - Code: 213
// newline

func Error

func Error(a ...any) (int, error)
Example
logger.Error("Unexpected character on line ", line, " column ", column)
Output:
ERROR Unexpected character on line 10 column 5

func Errorf

func Errorf(format string, a ...any) (int, error)
Example
logger.Errorf("Unexpected character on line %d column %d", line, column)
Output:
ERROR Unexpected character on line 10 column 5

func Errorln

func Errorln(a ...any) (int, error)
Example
logger.Errorln("Unexpected character on line ", line, " column ", column)
Output:
ERROR Unexpected character on line  10  column  5
// newline

func Fatal

func Fatal(a ...any)
Example
logger.Fatal("The required data '", foo, "' was missing")
Output:
FATAL The required data 'foo' was missing
// exit

func Fatalf

func Fatalf(format string, a ...any)
Example
logger.Fatalf("The required data '%s' was missing", foo)
Output:
FATAL The required data 'foo' was missing
// exit

func Fatalln

func Fatalln(a ...any)
Example
logger.Fatalln("The required data '", foo, "' was missing")
Output:
The required data ' foo ' was missing
// newline // exit

func Tip

func Tip(a ...any) (int, error)
Example
logger.Tip("To get more info, visit ", url, "#", id)
Output:
TIP To get more info, visit https://uynilo9.is-a.dev#213

func Tipf

func Tipf(format string, a ...any) (int, error)
Example
logger.Tipf("To get more info, visit %s#%d", url, id)
Output:
TIP To get more info, visit https://uynilo9.is-a.dev#213

func Tipln

func Tipln(a ...any) (int, error)
Example
logger.Tipln("To get more info, visit ", url, "#", id)
Output:
TIP To get more info, visit  https://uynilo9.is-a.dev # 213
// newline

func Warn

func Warn(a ...any) (int, error)
Example
logger.Warn("New version ", version, " has been released, please update")
Output:
WARN New version 3.14.159 has been released, please update

func Warnf

func Warnf(format string, a ...any) (int, error)
Example
logger.Warnf("New version %s has been released, please update", version)
Output:
WARN New version 3.14.159 has been released, please update

func Warnln

func Warnln(a ...any) (int, error)
Example
logger.Warnln("New version ", version, " has been released, please update")
Output:
WARN New version 3.14.159 has been released, please update
// newline

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址