Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sadlil/gologger
The Simplest and worst logging library ever written
https://github.com/sadlil/gologger
Last synced: about 1 month ago
JSON representation
The Simplest and worst logging library ever written
- Host: GitHub
- URL: https://github.com/sadlil/gologger
- Owner: sadlil
- Archived: true
- Created: 2015-09-02T08:52:26.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-01-31T03:17:58.000Z (almost 7 years ago)
- Last Synced: 2024-10-25T05:22:58.212Z (about 2 months ago)
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 42
- Watchers: 7
- Forks: 10
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-go - gologger - Simple Logger for golang. Logs Into console, file or ElasticSearch. Simple, easy to use. - ★ 38 (Logging)
- awesome-go-extra - ARCHIVED - 09-02T08:52:26Z|2018-01-31T03:17:58Z| (Logging / Advanced Console UIs)
- awesome-go-zh - gologger
README
# gologger
A Simple Easy to use go logger library. Displays Colored log into console in any unix or windows platform.
You can even store your logs in file, ElasticSearch or MySQL Database.#### Developed:
- Colored and Simple Log into Console
- File Logging
- ElasticSearch Logging#### How to Get:
``` sh
$ go get github.com/sadlil/gologger
```
#### How To Use:
``` go
import "github.com/sadlil/gologger"Console::
logger = gologger.GetLogger(gologger.CONSOLE, gologger.SimpleLog)
// Displays Simple plain log in consolelogger = gologger.GetLogger(gologger.CONSOLE, gologger.ColoredLog)
// Displays Colorful log in consoleFile::
logger = gologger.GetLogger(gologger.FILE, fileName)
// Log all the message in the given file.
// If file is not presents then creates it. if filename is "" creates
// a default file named logs.txt in ur project directory.ElasticSearch::
logger = gologger.GetLogger(gologger.ELASTICSEARCH, location)
// Logs everything into elasticsearch. if location is "" then it
// looks for elasticsearch by default in http://localhost:9200
// and logs stored in index 'gologger'.
// If you want to provide custom location and index for your log
// you must provide the location in this format
// "http://Your_ES_Url:ES_Port/Index",
// If you only want to change the default index name you can do that
// by sending "/YourIndex", it will use default localhost for ES.
```
#### Display:
``` go
logger.Log(Message) -> displays in console.
```
``` sh
[Log] [Time] [Package Name::File Name::Function Name] [Line Number] Message
```
#### Logger Functions Available:
``` go
logger.Log(message string)
logger.Message(message string)
logger.Info(message string)
logger.Warn(message string)
logger.Debug(message string)
logger.Error(message string)
```
#### You can use two or more same type or diffrent type logger in same application.
``` go
logger1 = gologger.GetLogger(gologger.CONSOLE, gologger.SimpleLog)
logger2 = gologger.GetLogger(gologger.FILE, "filelog.log")logger1.log("Hello Console") // loges into console.
logger2.log("Hello File") // loges into file.
```**Any suggestion and Issue would be highly appreciated**. You can create an issue or pull request
if you think i need to modify my library.#### Used Libraries
1. Color Console - [faith/color](https://github.com/fatih/color)
2. ElasticSearch - [olivere/elastic](https://github.com/olivere/elastic)