From 12eb9c89eb58a698e92690bf80fd3fd1db20ba38 Mon Sep 17 00:00:00 2001 From: Alex Bramley Date: Fri, 27 Sep 2013 22:31:33 +0100 Subject: [PATCH] Simple adapter to utilise GLog with goirc. --- logging/glog/glog.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 logging/glog/glog.go diff --git a/logging/glog/glog.go b/logging/glog/glog.go new file mode 100644 index 0000000..ff87725 --- /dev/null +++ b/logging/glog/glog.go @@ -0,0 +1,20 @@ +package glog + +import ( + "github.com/golang/glog" +) + +// Simple adapter to utilise Google's GLog package with goirc. +// Just import github.com/fluffle/goirc/logging and this package, +// then call logging.Logger(glog.GLogger{}). +// The unfortunate downside of this is that it adds an extra hop +// to the caller chain which means *all* the line numbers are bad. +type GLogger struct{} + +func (gl GLogger) Debug(f string, a ...interface{}) { + // GLog doesn't have a "Debug" level, so use V(2) instead. + glog.V(2).Infof(f, a...) +} +func (gl GLogger) Info(f string, a ...interface{}) { glog.Infof(f, a...) } +func (gl GLogger) Warn(f string, a ...interface{}) { glog.Warningf(f, a...) } +func (gl GLogger) Error(f string, a ...interface{}) { glog.Errorf(f, a...) }