Skip to content

A simple and colourful logger interface wrapper on-top of the standard library Log for printing formatted lines to the console.

License

Notifications You must be signed in to change notification settings

jamestkelly/go-logger-interface

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn


Logo

Go Logger Interface

A simple and colourful logger interface wrapper on-top of the standard library Log for printing formatted lines to the console.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Acknowledgments

About The Project

This project was made to address the need for myself in having a colourful, standardised output similar to LoggerInterface solutions available in other languages.

In short, this module is a wrapper on top of the standard library Log to output formatted logs to the terminal for a given service in the following format:

Example output

(back to top)

Built With

  • Go

(back to top)

Getting Started

Prerequisites

It is assumed that you already have Go installed on your machine.

  • go
    https://go.dev/doc/install # Follow the instructions to install Go

Installation

  1. Import the module to your project.
    go get github.com/jamestkelly/go-logger-interface

(back to top)

Usage

To utilise the package after installing the module, simply create a logger interface at the top of your given file and use it like so:

// example.go
import (
    github.com/jamestkelly/go-logger-interface
)

var (
    exampleLogger = logger.LoggerInterface{Prefix: "ExampleLoggerInterface"}
)

// main
// Example main function to log a bunch of statements using LoggerInterface
func main() {
	exampleLogger.LogMessage(
		"This is a 'DEBUG' message.",
		"DEBUG",
	)

	exampleLogger.LogMessage(
		"This is an 'INFO' message.",
		"INFO",
	)

	exampleLogger.LogMessage(
		fmt.Sprintf("This is a %s 'INFO' message.", "formatted"),
		"INFO",
	)

	exampleLogger.LogMessage(
		"This is a 'WARN' message.",
		"WARN",
	)

	exampleLogger.LogMessage(
		"This is an 'ERROR' message.",
		"ERROR",
	)

	exampleLogger.LogMessage(
		"This is a 'FATAL' message.",
		"FATAL",
	)
}

For more examples, please refer to the Examples

(back to top)

Roadmap

  • Create the package and make it available publically.

See the open issues for a full list of proposed features (and known issues).

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Jim Kelly - [email protected]

Project Link: https://github.com/jamestkelly/go-logger-interface

(back to top)

Acknowledgments

(back to top)

About

A simple and colourful logger interface wrapper on-top of the standard library Log for printing formatted lines to the console.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages