Hi, in this article we’ll talk and implement AR-Logger which is a Golang logging system & package.
—
This package was developed by ABDO-AR to make the debugging easier & faster, package features are the following:
- Displaying logs with modern design
- Generating logs file that contain all logs with their information in JSON format for use it in the administration application or in REST API as well as for debugging.
—
Implementation:
package main
import "ar_logger/logger"
// Main:
func main() {
// Setup:
logger.SetupLoggingSystem("./logs/logs.json") // Pass empty string will make it log into "./logs.json".
// Logging:
logger.E("Authentication API", "Failed to authenticate user(2131)!")
logger.W("Authentication API", "Authentication is currently disabled, please turn it on!")
logger.I("Authentication API", "10,000 Users was authenticated in this month.")
logger.S("Authentication API", "User(2131) was authenticated successfully")
}
Output:
Package link is:
ABDO-AR/ar_logger: A new modern Golang logger system. (github.com)