Skip to content

sprout-log/core

Repository files navigation

LogKer

logker It's a log Library of Golang. It's easy to use.👨‍💻‍

📚中文说明 | 🤩Pkg.go.dev | 👨‍💻‍ Release


The current warehouse is a copy~
If you want to check the latest updates, please go to this warehouse https://github.com/higker/logker

Features

  • Support file backup.
  • Simple and easy to use.
  • Support file storage log.
  • Support console color printing.
  • Custom log file storage location.
  • Support setting time and time zone.
  • Support log file size for split storage.
  • Error level output to specified file separately.
  • Four levels of debug info error warning are supported.
  • Future support: The remote computer stores the websoket output🙏.
  • The project is constantly maintained and updated. I like 😍A kind of Please click star Thanks♪(・ω・)ノ!

Installation

🔝 The minimum requirement of Go version is 1.11. 🔝 Your project also uses go module!!!

go get github.com/higker/logker

OR

go get -u github.com/higker/logker

command add -u flag to update in the future.

Use Example

1. File Logger

package main

import (
	klog "github.com/higker/logker"
	"time"
)

func main() {
	// Specify file location! Create folder in advance!!
	dir := "/Users/ding/Documents/test_log"
	// New file logger
	// File Max size : You can also use built-in constants
	// klog.GB1  	= 1GB
	// klog.MB10  	= 10MB
 	// klog.MB100	= 100MB
	flog := klog.NewFlog(klog.DEBUG, true, klog.Shanghai, dir, "log", 10*1024, 0777)
	// Analog output log
	for {
		flog.Debug("DEBUG : %d + %d = %d",1,2,1+2)
		flog.Error("ERROR")
		flog.Warning("WARNING %p",flog)
		flog.Info("INFO %s","Hello LogKer.")
		time.Sleep(2 * time.Second)
	}
}

👆Parameter note List:

// Build File logger
// Args note
// logLevel:    lev,       \\ logging level
// wheError:    wheErr,    \\ whether enable  error alone file
// directory:   dir,	   \\ logging file save directory
// fileName:    fileName,  \\ logging save file name
// timeZone:    zone,	   \\ load time zone format
// power:       power,     \\ file system power
// fileMaxSize: size,      \\ logging alone file max size

2. Console Logger

package main

import (
	klog "github.com/higker/logker"
	"time"
)

func main() {
	// New Console logger
	clog := klog.NewClog(klog.DEBUG,klog.Shanghai)
	clog.Debug("DEBUG : %d + %d = %d",1,2,1+2)
	clog.Error("ERROR")
	clog.Warning("WARNING %p",clog)
	clog.Info("INFO %s","Hello LogKer.")
}

3. Effect:

LogKerGolang

log,golang,logKer

Thank list🤝

Other

License

This project open source is MIT License . See the LICENSE file content.

About

👨‍💻‍Logker for Golang simple logging library🚀| Logker 是一个简单易用的go语言日志库🔥

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages