Giter VIP home page Giter VIP logo

gologger's Introduction

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:

$ go get github.com/sadlil/gologger

How To Use:

import "github.com/sadlil/gologger"

Console::
logger = gologger.GetLogger(gologger.CONSOLE, gologger.SimpleLog)
// Displays Simple plain log in console

logger = gologger.GetLogger(gologger.CONSOLE, gologger.ColoredLog)
// Displays Colorful log in console


File::
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:

logger.Log(Message) -> displays in console.
[Log] [Time] [Package Name::File Name::Function Name] [Line Number] Message

Logger Functions Available:

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.

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
  2. ElasticSearch - olivere/elastic

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.