summaryrefslogtreecommitdiffstats
path: root/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2015-11-26 09:02:00 -0500
committerChristopher Speller <crspeller@gmail.com>2015-11-26 09:02:00 -0500
commit006fc61ecce1ba3d5c7b7163309467c24edbbc46 (patch)
tree533f5dcd094ebd94d425e64a4261b7b21ec6f3fa /Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go
parentaaced173f8b3020fbbef236d84b070c2c67ee968 (diff)
parent2639452967e66c4840164c36817234d3e7c12ac1 (diff)
downloadchat-006fc61ecce1ba3d5c7b7163309467c24edbbc46.tar.gz
chat-006fc61ecce1ba3d5c7b7163309467c24edbbc46.tar.bz2
chat-006fc61ecce1ba3d5c7b7163309467c24edbbc46.zip
Merge pull request #1505 from mattermost/lib-upgrade
Lib upgrade
Diffstat (limited to 'Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go')
-rw-r--r--Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go44
1 files changed, 44 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go b/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go
new file mode 100644
index 000000000..89d6c0e79
--- /dev/null
+++ b/Godeps/_workspace/src/github.com/go-gorp/gorp/logging.go
@@ -0,0 +1,44 @@
+// Copyright 2012 James Cooper. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+// Package gorp provides a simple way to marshal Go structs to and from
+// SQL databases. It uses the database/sql package, and should work with any
+// compliant database/sql driver.
+//
+// Source code and project home:
+// https://github.com/go-gorp/gorp
+
+package gorp
+
+import "fmt"
+
+type GorpLogger interface {
+ Printf(format string, v ...interface{})
+}
+
+// TraceOn turns on SQL statement logging for this DbMap. After this is
+// called, all SQL statements will be sent to the logger. If prefix is
+// a non-empty string, it will be written to the front of all logged
+// strings, which can aid in filtering log lines.
+//
+// Use TraceOn if you want to spy on the SQL statements that gorp
+// generates.
+//
+// Note that the base log.Logger type satisfies GorpLogger, but adapters can
+// easily be written for other logging packages (e.g., the golang-sanctioned
+// glog framework).
+func (m *DbMap) TraceOn(prefix string, logger GorpLogger) {
+ m.logger = logger
+ if prefix == "" {
+ m.logPrefix = prefix
+ } else {
+ m.logPrefix = fmt.Sprintf("%s ", prefix)
+ }
+}
+
+// TraceOff turns off tracing. It is idempotent.
+func (m *DbMap) TraceOff() {
+ m.logger = nil
+ m.logPrefix = ""
+}