aboutsummaryrefslogtreecommitdiff
path: root/plugin/pkg/log/plugin_test.go
diff options
context:
space:
mode:
authorGravatar Miek Gieben <miek@miek.nl> 2018-11-15 22:18:49 +0000
committerGravatar GitHub <noreply@github.com> 2018-11-15 22:18:49 +0000
commit3f6dfba1f0e9cd6c858f88891550d09904b7814d (patch)
tree04fdb7cf24fef14fcd347ab6a7e13a1144d28774 /plugin/pkg/log/plugin_test.go
parent669b99d91c5eaf4c669d03436083c98e3c298367 (diff)
downloadcoredns-3f6dfba1f0e9cd6c858f88891550d09904b7814d.tar.gz
coredns-3f6dfba1f0e9cd6c858f88891550d09904b7814d.tar.zst
coredns-3f6dfba1f0e9cd6c858f88891550d09904b7814d.zip
Redo the plugin log PR (#2315)
* Redo the plugin log PR Remove the code duplication and call of the "official" functions. This is the second(?) time we forgot to update the other half, so remove that problem entirely. Also add a test if the correct (within limits) time in front of the log line. Signed-off-by: Miek Gieben <miek@miek.nl> * Remove pFormat Signed-off-by: Miek Gieben <miek@miek.nl>
Diffstat (limited to 'plugin/pkg/log/plugin_test.go')
-rw-r--r--plugin/pkg/log/plugin_test.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/plugin/pkg/log/plugin_test.go b/plugin/pkg/log/plugin_test.go
index b24caa48b..c02338608 100644
--- a/plugin/pkg/log/plugin_test.go
+++ b/plugin/pkg/log/plugin_test.go
@@ -19,3 +19,19 @@ func TestPlugins(t *testing.T) {
t.Errorf("Expected log to be %s, got %s", info+ts, x)
}
}
+
+func TestPluginsDateTime(t *testing.T) {
+ var f bytes.Buffer
+ const ts = "test"
+ golog.SetFlags(0) // Set to 0 because we're doing our own time, with timezone
+ golog.SetOutput(&f)
+
+ lg := NewWithPlugin("testplugin")
+
+ lg.Info(ts)
+ // rude check if the date/time is there
+ str := f.String()
+ if str[4] != '-' || str[7] != '-' || str[10] != 'T' {
+ t.Errorf("Expected date got %s...", str[:15])
+ }
+}