| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- /*
- * EliasDB
- *
- * Copyright 2016 Matthias Ladkau. All rights reserved.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
- package ecal
- import (
- "fmt"
- "testing"
- )
- func TestLogging(t *testing.T) {
- ml := NewMemoryLogger(5)
- ml.LogDebug(nil, "test")
- ml.LogInfo(nil, "test")
- if ml.String() != `debug: test
- info: test` {
- t.Error("Unexpected result:", ml.String())
- return
- }
- if res := fmt.Sprint(ml.Slice()); res != "[debug: test info: test]" {
- t.Error("Unexpected result:", res)
- return
- }
- ml.Reset()
- ml.LogError(nil, "test1")
- if res := fmt.Sprint(ml.Slice()); res != "[error: test1]" {
- t.Error("Unexpected result:", res)
- return
- }
- if res := ml.Size(); res != 1 {
- t.Error("Unexpected result:", res)
- return
- }
- // Test that the functions can be called
- nl := NewNullLogger()
- nl.LogDebug(nil, "test")
- nl.LogInfo(nil, "test")
- nl.LogError(nil, "test")
- sol := NewStdOutLogger()
- sol.(*StdOutLogger).stdlog = func(v ...interface{}) {}
- sol.LogDebug(nil, "test")
- sol.LogInfo(nil, "test")
- sol.LogError(nil, "test")
- }
|