Git Product home page Git Product logo

aurlog's Introduction

aurlog

Build Status

Simple file-based wrapper for the standard Go log

###Installation

$ go get github.com/aurlaw/aurlog

Getting Started

package main

import "github.com/aurlaw/aurlog"

func main() {
	lc := aurlog.LogConfiguration{LogFile: "server.log"}

	alog := aurlog.Configure(&lc)

	alog.Debugln("Here is a debug log")
	alog.Infoln("Here is a info log")
	alog.Warningln("Here is a warning log")
	alog.Errorln("Here is a error log")

}

Executing this program will create a 'server.log' file with the following entries

DEBUG: 2014/08/31 00:47:22 [Here is a debug log]
INFO: 2014/08/31 00:47:22 [Here is a info log]
WARNING: 2014/08/31 00:47:22 [Here is a warning log]
ERROR: 2014/08/31 00:47:22 [Here is a error log]

Configuration

The following log types are supported:

  • Debug
  • Info
  • Warning
  • Error
  • Fatal

Debug, Info, Warning & Error support the Print, Printf & Println from the Standard Go Log

i.e. Debug, Debugf, Debugln, etc.

Fatal support the Fatal, Fatalf & Fatalln from the Standard Go Log

Log Levels

The following log levels can be enabled

  • IsDebug - true or false. Defaults to true if no log level is configured.
  • IsInfo - true or false. Defaults to true if no log level is configured.
  • IsWarning - true or false. Defaults to true if no log level is configured.
  • IsError - true or false. Defaults to true if no log level is configured.
	lc := aurlog.LogConfiguration{}
	lc.IsInfo = true
	lc.IsError = true

Additional Configuration

  • LogFile - defines the log file. All logfiles are prepended with the current date in yyyy-mm-dd format. If not supplied, uses the StdOut and StdErr defined by the Standard Go Log. LogFile can contain an absolute or relative path
  • NoStdOut - if set to true, disables logging to the StdOut or StdErr. False by default
	lc := aurlog.LogConfiguration{LogFile: "test.log", NoStdOut: true}
	lc.IsInfo = true
	lc.IsError = true

Full Sample

package main

import "github.com/aurlaw/aurlog"

func main() {
	lc := aurlog.LogConfiguration{LogFile: "server.log"}
	lc.IsInfo = true
	lc.IsError = true

	alog := aurlog.Configure(&lc)

	alog.Debugln("Here is a debug log")
	alog.Infoln("Here is a info log")
	alog.Warningln("Here is a warning log")
	alog.Errorln("Here is a error log")

}

Executing this program will create a 'server.log' file with the following entries

INFO: 2014/08/31 00:47:22 [Here is a info log]
ERROR: 2014/08/31 00:47:22 [Here is a error log]

aurlog's People

Contributors

aurlaw avatar

Watchers

James Cloos avatar  avatar

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.