All Projects → corgi-kx → Logcustom

corgi-kx / Logcustom

A simple log customization tool based on golang 一个基于golang简单的日志定制化工具

Programming Languages

go
31211 projects - #10 most used programming language
golang
3204 projects

Projects that are alternatives of or similar to Logcustom

printer
A fancy logger yet lightweight, and configurable. 🖨
Stars: ✭ 65 (+41.3%)
Mutual labels:  log, logger, print
ip-logger
📇 When someone clicks the link, you will receive their IP and other information via telegram.
Stars: ✭ 0 (-100%)
Mutual labels:  log, logger
polog
Логирование должно быть красивым
Stars: ✭ 26 (-43.48%)
Mutual labels:  log, logger
gxlog
A concise, functional, flexible and extensible logger for go.
Stars: ✭ 65 (+41.3%)
Mutual labels:  log, logger
laravel-loggable
🎥 📽 🎞 Log your model changes in multiple ways
Stars: ✭ 58 (+26.09%)
Mutual labels:  log, logger
dlog
A super simple logger for Go. Supports stderr, logfiles, syslog and windows event log.
Stars: ✭ 16 (-65.22%)
Mutual labels:  log, logger
horse-logger
Middleware for access logging in HORSE
Stars: ✭ 25 (-45.65%)
Mutual labels:  log, logger
logt
🖥️ A colourful logger for the browser
Stars: ✭ 35 (-23.91%)
Mutual labels:  log, logger
Cocoadebug
iOS Debugging Tool 🚀
Stars: ✭ 3,769 (+8093.48%)
Mutual labels:  log, logger
Objectlogger
A powerful and easy-to-use operational logging system that supports analysis of changes in object properties. 强大且易用的操作日志记录系统,支持对象属性的变化分析。
Stars: ✭ 378 (+721.74%)
Mutual labels:  log, logger
Eylogviewer
A simple viewer to see your app's logs on your iDevice in realtime.
Stars: ✭ 16 (-65.22%)
Mutual labels:  log, logger
ctrace-go
Canonical OpenTracing for GoLang
Stars: ✭ 12 (-73.91%)
Mutual labels:  log, logger
debug.js
Debugger of JavaScript, by JavaScript, for JavaScript
Stars: ✭ 19 (-58.7%)
Mutual labels:  log, logger
Gollum
An n:m message multiplexer written in Go
Stars: ✭ 883 (+1819.57%)
Mutual labels:  log, logger
react-native-log-level
Multi level logger for React Native
Stars: ✭ 13 (-71.74%)
Mutual labels:  log, logger
Activity
A PHP API to log anything anywhere
Stars: ✭ 44 (-4.35%)
Mutual labels:  log, logger
mongoose-morgan
An npm package for saving morgan log inside MongoDB
Stars: ✭ 14 (-69.57%)
Mutual labels:  log, logger
spdlog setup
spdlog setup initialization via file configuration for convenience.
Stars: ✭ 68 (+47.83%)
Mutual labels:  log, logger
esp-logger
An Arduino library providing a minimal interface to log data on flash memory and SD cards with ESP8266 and ESP32
Stars: ✭ 40 (-13.04%)
Mutual labels:  log, logger
Laravel Log
Simple API to write logs for Laravel.
Stars: ✭ 19 (-58.7%)
Mutual labels:  log, logger

golang日志小工具


花了几天时间写了个golang日志小工具,基本满足日常开发需求

特点

  • 支持定向输出日志到指定文件
  • 支持隐藏调试信息
  • 支持彩色打印(windows/linux/mac均支持)
  • 显示输出日志的类名、函数/方法名

Feature

  • Supports directing output logs to specified files
  • Support for hiding debugging information
  • Support color printing (Windows/Linux/MAC)
  • Displays the class name, function/method name of the output log

源码地址: https://github.com/corgi-kx/logcustom


示例 Example


打印效果:

Example Output

使用示范

package main

import (
	log "github.com/corgi-kx/logcustom"
	"os"
)

func main() {
	//直接调用log,则是全局使用
	log.Info("Write something you want to print !")
	log.Warn("Write something you want to print !")
	log.Trace("Write something you want to print !")
	log.Debug("Write something you want to print !")
	log.Error("Write something you want to print !")

	//设置输出信息隐藏等级
	err := log.SetLogDiscardLevel(log.Leveldebug)
	if err != nil {
		log.Error(err)
	}

	log.Info("SetLogDiscardLevel test  !") //INFO不会被打印
	log.Debug("SetLogDiscardLevel test  !")
	log.Warn("SetLogDiscardLevel test  !")

	//创建新的日志对象
	mylog := log.New()
	file, err := os.OpenFile("log.txt", os.O_CREATE|os.O_APPEND|os.O_WRONLY, 0666)
	if err != nil {
		log.Error(err)
	}
	//将日志信息输出到指定文件
	mylog.SetOutputAbove(file, log.Levelwarn) //WARN及WARN以上级别的日志会输出到指定文件
	mylog.Trace("SetOutputAll test !")
	mylog.Info("SetOutputAll test  !")
	mylog.Debug("SetOutputAll test  !")
	mylog.Warn("SetOutputAll test  !")
	mylog.Error("SetOutputAll test  !")
}



安装 Installing


go get github.com/corgi-kx/logcustom

安装成功后,日志包就可以使用了,包位置在

$GOPATH/src/github.com/corgi-kx/logcustom

您可以使用 go get -u 对此包进行更新

文档 Documentation


您可以使用以下命令来查看使用文档

godoc github.com/corgi-kx/logcustom

或者在终端输入如下命令:

godoc -http=:6060

在浏览器访问此界面

http://127.0.0.1:6060/pkg/github.com/corgi-kx/logcustom/
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].