All Projects → syrinsecurity → gologger

syrinsecurity / gologger

Licence: Apache-2.0 license
A concurrent, fast queue/service worker based filesystem logging system perfect for servers with concurrent connections

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to gologger

Android Filelogger
A general-purpose logging library with built-in support to save logs to file efficiently.
Stars: ✭ 70 (+337.5%)
Mutual labels:  log, file
Eager Image Loader
The eager-loading for image files on the web page that loads the files according to your plan. This differs from the lazy-loading, for example, this can be used to avoid that the user waits for the loading.
Stars: ✭ 22 (+37.5%)
Mutual labels:  fast, file
Go Logger
一个简单而强大的 golang 日志工具包,支持同步和异步输出到 命令行,文件, api 接口,文件支持按文件大小,文件行数,日期切分;A simple and powerful golang logging toolkit that supports synchronous and asynchronous output to the console, file, API interfaces, file support by file size, file line number, date sharding.
Stars: ✭ 152 (+850%)
Mutual labels:  log, file
Naza
🍀 Go basic library. || Go语言基础库
Stars: ✭ 253 (+1481.25%)
Mutual labels:  log, file
log-target-file
Yii Logging Library - File Target
Stars: ✭ 19 (+18.75%)
Mutual labels:  log, file
Tank
A very high performance distributed log service
Stars: ✭ 927 (+5693.75%)
Mutual labels:  log, service
Nupdate
A comfortable update solution for .NET-applications.
Stars: ✭ 394 (+2362.5%)
Mutual labels:  fast, service
Xlog
Android logger, pretty, powerful and flexible, log to everywhere, save to file, all you want is here.
Stars: ✭ 2,468 (+15325%)
Mutual labels:  log, file
TLog
Android日志工具
Stars: ✭ 16 (+0%)
Mutual labels:  log, file
gtree
Output tree🌳 or Make directories📁 from #Markdown or Programmatically. Provide CLI, Golang library and Web (using #Wasm ).
Stars: ✭ 88 (+450%)
Mutual labels:  service-worker, file
Pwa Cookbook
personally website
Stars: ✭ 107 (+568.75%)
Mutual labels:  service-worker, service
aushape
A library and a tool for converting audit logs to XML and JSON
Stars: ✭ 37 (+131.25%)
Mutual labels:  log, file
Steno
Specialized fast async file writer
Stars: ✭ 236 (+1375%)
Mutual labels:  file, safe
Androidutilcode
AndroidUtilCode 🔥 is a powerful & easy to use library for Android. This library encapsulates the functions that commonly used in Android development which have complete demo and unit test. By using it's encapsulated APIs, you can greatly improve the development efficiency. The program mainly consists of two modules which is utilcode, which is commonly used in development, and subutil which is rarely used in development, but the utils can be beneficial to simplify the main module. 🔥
Stars: ✭ 30,239 (+188893.75%)
Mutual labels:  log, file
Ataraxia
Simple and lightweight source-based multi-platform Linux distribution with musl libc.
Stars: ✭ 226 (+1312.5%)
Mutual labels:  fast, safe
sprout
Golang logging library supporting log retrieval.
Stars: ✭ 85 (+431.25%)
Mutual labels:  log, file
Mimir
📱 A simple & efficient iOS logging framework for high usage apps
Stars: ✭ 13 (-18.75%)
Mutual labels:  fast, log
safe-typeorm
TypeORM helper library enhancing safety in the compilation level
Stars: ✭ 160 (+900%)
Mutual labels:  safe
transfer-sh
Node.js CLI tool for easy file sharing using Transfer.sh
Stars: ✭ 24 (+50%)
Mutual labels:  file
stone paper scissor defeator using opencv keras
In this repository i tried to replicate a cool project by a japanese scientist who made a machine which had 100 % accuracy in defeating humans in the game of stone-paper and scissors
Stars: ✭ 22 (+37.5%)
Mutual labels:  fast

Gologger

Go report card Build Status GoDoc Maintenance License GitHub release GitHub issues PRs Welcome

Gologger is a concurrent thread safe logging system which writes to the filesystem. Gologger utilises a service worker model with buffered channels/queues. No need to worry about leaking file descriptors as Gologger only opens one descriptor per file.

  • Non blocking, uses a queue whith a service worker to proccess logs.
  • Thread/Concurrent safe.
  • Supports any data type! Supports interface{} type.
  • Use logger just like fmt, provide as many arguments as you need.
  • Advanced features such as naming conventions e.g. logs-Jul-2020.txt

Install

go get github.com/syrinsecurity/gologger

Basic Examples

Custom loggers

func main() {

	/*
	"./file.log" is where the logs will be written to. If this file does not exist it will be created.

	"200" is the buffer size of the channel
	*/
	logger, err := gologger.New("./file.log", 200)
	if err != nil {
		panic(err)
	}

	logger.WriteString("log any data you want.")
	logger.WriteString("This is a interface so you can use any type you like.", "UserID:", 9039832898, "Timestamp:", time.Now().Unix())
}
package main

import "github.com/syrinsecurity/gologger"

var (
	logger, _ = gologger.New("./file.log", 200)
)

func main() {
	logger.Write("data", 123, 345)
}

Use the built in loggers for fast setup

package main

import "github.com/syrinsecurity/gologger"

func main() {

	//Start the service worker
	//Leave the path blank for loggers you do not want to use
	go gologger.Service("./error.log", "", "")

	gologger.Write(gologger.LogError, "error data")

	//Quick logger syntax
	gologger.Error.Write(errors.New("example error"))
}

Advanced Usage

package main

import (
	"github.com/syrinsecurity/gologger"
)

type structExample struct {
	Feild1 string
	Feild2 string
}

func main() {
	//Create a new custom logger
	log := gologger.NewCustomLogger("./logs-", ".txt", 0)

	//This will make the filename update every month for example: logs-Jul-2020.txt
	gologger.SetNameConventionMonthYear(log)

	//Start the logger service on another goroutine
	go log.Service()

	//Make sure to close the logger
	defer log.Close()

	//write multipule values to the log with any data type
	log.Write("test", 1, 2, 2)

	//Convert any object to JSON and write it to the log
	log.WriteJSON(structExample{
		Feild1: "value1",
		Feild2: "value2",
	})

	//Byte arrays are written directly to the file, meaning no additional formating like fmt would
	log.Write([]byte{0, 3, 86, 32})

}

Naming conventions

  • SetNameConventionMonthYear() Jan-2006
  • SetNameConventionYear() 2006
  • SetNameConventionDayMonthYear() Monday-Jan-2006

You can create your own naming conventions by setting logger.NamingConvention to equal a func() string of your choosing. Note By default the naming convention returns a empty string. If you do not want to use a naming convention you can just not modify the default.

Settings

  • LineTerminator - Appends a suffix to the end of the log, default is "\n"
  • ValueSeperator - Is the value inbetween each value insert when you use multipule values on the write method, default is " "
  • ConventionUpdate - Determins how often the filename should be checked for new changes
  • Extention - This is your file extention what is appened after the name convention
  • Path - This is where you want to store the log file, it also includes the start of the filename

Methods & Callbacks

  • Close() - This will shutdown the service worker
  • ConventionUpdated(oldFile string, newFile string) - This call back is returned when the naming convention has changed thus a new log file has been created.
    • You could use this callback to backup the "old" log file.

Get the size of all basic queues:

gologger.QueueSize()

For more examples look at https://github.com/syrinsecurity/gologger/tree/master/examples

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].