예제 #1
0
파일: simple.go 프로젝트: teespring/logger
package main

import (
	"time"

	"github.com/teespring/logger"
)

var log = logger.New("app")

func main() {
	log.Info("Starting at %d", 9088)

	log.Info("Requesting an image at foo/bar.jpg")
	timer := log.Timer()
	time.Sleep(time.Millisecond * 250)
	timer.End("Fetched foo/bar.jpg")

	log.Error("Failed to start, shutting down...")
}
예제 #2
0
package main

import (
	"errors"
	"time"

	"github.com/teespring/logger"
)

var app = logger.New("app")
var images = logger.New("images")
var socket = logger.New("websocket")
var users = logger.New("users")
var db = logger.New("database")

func main() {
	app.Info("Starting at %d", 9088)
	db.Info("Connecting to mysql://azer@localhost:9900/foobar")

	images.Info("Requesting an image at foo/bar.jpg")
	timer := images.Timer()
	time.Sleep(time.Millisecond * 250)
	timer.End("Fetched foo/bar.jpg")

	db.Error("Fatal connection error.")

	users.Info("%s just logged  from %s", "John", "Istanbul")

	socket.Info("Connecting...")

	err := errors.New("Unable to connect.")
예제 #3
0
파일: attrs.go 프로젝트: teespring/logger
package main

import (
	"errors"
	"time"

	"github.com/teespring/logger"
)

var log = logger.New("e-mail")

func main() {
	log.Info("Sending an e-mail", logger.Attrs{
		"from": "*****@*****.**",
		"to":   "*****@*****.**",
	})

	err := errors.New("Too busy")

	log.Error("Failed to send e-mail. Error: %s", err, logger.Attrs{
		"from": "*****@*****.**",
		"to":   "*****@*****.**",
	})

	timer := log.Timer()
	time.Sleep(time.Millisecond * 500)
	timer.End("Created a new %s image", "bike", logger.Attrs{
		"id":    123456,
		"model": "bmx",
		"frame": "purple",
		"year":  2014,