GithubHelp home page GithubHelp logo

log-1's Introduction

Golang Log

format,colorful,level log and redirect escape log.

asciinema FOSSA Status

 Recommended: [%D %T] [%L] (%S) %M
NO Format Details Output Example
1 %T Time 15:04:05 MST
2 %t Time 15:04
3 %D Date 2006/01/02
4 %d Date 01/02/06
5 %L Level DEBUG,INFO,WARNING,ERROR
6 %S Source filename,lineno,funcname
7 %M Message output text

Level Define

NO Level Details
1 DEBUG for debug output
2 INFO for general output
3 WARN for warnning output
4 ERROR for error output
5 FATAL for fatal output

Log Install

go get -u github.com/flyaways/log

Get started

package main

import (
	"fmt"
	"os"
	"os/signal"

	"github.com/flyaways/log"
)

func init() {
	//Collector for escape ouput
	log.Collector()
}

func main() {
	op := log.New(
		log.LogConfig{
			Level:         log.INFO,
			FirstRollover: true,
			Blocking:      false,
			BufferLength:  10240,
			PrefixName:    "op.log",
			When:          log.Hour,
			BackupCount:   72,
			Format:        log.OpFormat}, //log.AccessFormat
	)

	if op == nil {
		fmt.Fprintf(os.Stderr, "init logger error\n")
		return
	}

	op.Debug("Go is an open source project developed by a team at Google and many contributors from the open source community.")
	op.Info("Go is distributed under a BSD-style license.")
	op.Warn("A low traffic mailing list for important announcements, such as new releases.")
	op.Error("We encourage all Go users to subscribe to golang-announce.")
	//op.Fatal("Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.")

	signals := make(chan os.Signal, 1)
	signal.Notify(signals, os.Interrupt)
	<-signals
}

Reference

Lisence

License

FOSSA Status

log-1's People

Contributors

flyaways avatar fossabot avatar

Stargazers

 avatar

Watchers

 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.