Giter VIP home page Giter VIP logo

sprout's Introduction

⚠️ 本库是本人在入坑go一个星期的时候写出来的,代码质量有点差,谨慎使用!,后面有空将会重构。

LogKer

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

📚中文说明 | 🤩Document | 👨‍💻‍ Release


Video link

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 socket output🙏.
  • The project is constantly maintained and updated. I like 😍A kind of Please click star Thanks♪(・ω・)ノ!
  • Is this you?😜

Upgrade List

  • v1.1.5 Support for custom message formats.(SerialVersion) issues1
  • v1.1.8 Support coroutine to record logs,The code base is smaller and lighter(AsynchronousProcessingVersion).

Historical Documents

The Documents version is v1.1.8

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
	format := "{level} - DATE {time}  - POS {position} - MSG {message}" //This version was modified from v 1.1.5
	//Create Log Buffer
    	task := InitAsync(Qs1w)
   	flog,e := klog.NewFlog(klog.DEBUG, true, klog.Shanghai, dir, "log", 10*1024, 0777,format,task)
    	if e != nil{
       	    .... //Custom Operation
   	}
	// 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
// task := InitAsync(Qs1w) \\ createsABufferForCoroutineLogProcessing
// format :
	// Now upgrade to version v 1.1.5 to customize the message output format ~
	// TheCustomTagNameMustBe {level} {time} {position} {message}
	// The location of the custom label is the location
	// where the program outputs the corresponding log message at run time!!!!
	// forExampleHereIsMyCustom
	// 1. //format := "{level} - {time} - {position} - {message}"

2. Console Logger

package main

import (
	"github.com/higker/logker"
	"strings"
)

//type Formatting string

// logKer library Test
func main() {
	// Now upgrade to version v 1.1.5 to customize the message output format ~
	// TheCustomTagNameMustBe {level} {time} {position} {message}
	// The location of the custom label is the location
	// where the program outputs the corresponding log message at run time!!!!
	// forExampleHereIsMyCustom
	// 1. //format := "{level} - {time} - {position} - {message}"
	format := "{level} - 时间 {time}  - 位置 {position} - 消息 {message}" //This version was modified from v 1.1.5
    	//Create Log Buffer
    	task := InitAsync(Qs1w)
	log,e := logker.NewClog(logker.DEBUG, logker.Shanghai, format,task)
    	if e != nil{
        	..... //Custom Operation
    	}
	log.Debug("DEBUG %s","自定义日志消息匹配符测试")
	log.Info("%v", log)
	log.Warning("%v", logker.Shanghai)
	log.Error("ERROR")
}

OutPut

[ DEBUG ] - 时间 2020-04-20 11:57:23.8927  - 位置 main.go|main.main:23 - 消息 DEBUG 自定义日志消息匹配符测试
[  INFO ] - 时间 2020-04-20 11:57:23.8928  - 位置 main.go|main.main:24 - 消息 &{0 Asia/Shanghai 0xc00008e220 {level} - 时间 {t位置 {position} - 消息 {message}}
[WARNING] - 时间 2020-04-20 11:57:23.8928  - 位置 main.go|main.main:25 - 消息 Asia/Shanghai
[ ERROR ] - 时间 2020-04-20 11:57:23.8929  - 位置 main.go|main.main:26 - 消息 ERROR

3. Effect:

The screenshot is not updated ~ The current screenshot is v1.0.9 version, you can install the library yourself to see the effect. LogKerGolang

log,golang,logKer

Thank list🤝

Other

License

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

sprout's People

Contributors

auula avatar runthem avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sprout's Issues

单词拼写错误

file.go文件中常量定义的perfix单词拼错了(doge), 应该是prefix
我猜, 你应该是想定义一个文件后缀的字符串常量
 ̄□ ̄||

关于日志的输出信息

现在的日志输出信息:

[ INFO ] - Date: 2020-22-22 11:22:33.1234 AM - Position: main.go|main.main|22 - Message: custom message

能不能提供一个选项,可以去掉 Date:Position: 以及 Message: 这几个文本,因为很显而易见这栏就是时间,这栏就是代码位置,感觉没有必要,加上也增大了日志每行的长度

最终的效果就是

[ INFO ] - 2020-22-22 11:22:33.1234 AM - main.go|main.main|22 - custom message

另外这个 AM / PM 是否有必要存在呢,既然都已经是 24 小时制了?

panic: core init set time zone fail.

goroutine 1 [running]:
github.com/higker/logker.(*timeZone).localTime(0xc000092080, 0x502eb8, 0xa33de0, 0xb62e20)
D:/GoWroks/pkg/mod/github.com/higker/[email protected]/time.go:71 +0x128
github.com/higker/logker.(*timeZone).NowTimeStr(0xc000092080, 0x80, 0xc0000c0080)
D:/GoWroks/pkg/mod/github.com/higker/[email protected]/time.go:53 +0x32
github.com/higker/logker.(*fileLog).pack(0xc00009a080, 0x3, 0xc0000c0080, 0x7c, 0x1)
D:/GoWroks/pkg/mod/github.com/higker/[email protected]/message.go:25 +0x3a
github.com/higker/logker.(*fileLog).Error(0xc00009a080, 0xb8f9f5, 0x19, 0xc000092090, 0x1, 0x1)
D:/GoWroks/pkg/mod/github.com/higker/[email protected]/file.go:122 +0x9e

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.