blob: 617df60e8b0e0701eca426cd4830c9ef76f549db [file] [log] [blame]
Cosmos Nicolaou0e4e3922015-06-10 16:30:09 -07001// Copyright 2015 The Vanadium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package logger_test
6
7import (
8 "testing"
9
10 "v.io/x/lib/vlog"
11
Cosmos Nicolaou9691e5d2015-06-17 12:24:35 -070012 "v.io/v23/context"
Cosmos Nicolaou0e4e3922015-06-10 16:30:09 -070013 "v.io/v23/logging"
14
15 "v.io/x/ref/internal/logger"
16)
17
18func TestManager(t *testing.T) {
19 global := logger.Global()
20 if _, ok := global.(*vlog.Logger); !ok {
21 t.Fatalf("global logger is not a vlog.Logger")
22 }
23
24 manager := logger.Manager(logger.Global())
25 if _, ok := manager.(*vlog.Logger); !ok {
26 t.Fatalf("logger.Manager does not return a vlog.Logger")
27 }
28
29 // Make sure vlog.Log satisfies the logging interfaces
30 var _ logger.ManageLog = vlog.Log
31 var _ logging.Logger = vlog.Log
Cosmos Nicolaou9691e5d2015-06-17 12:24:35 -070032
33 // Make sure context.T implements logging.T
34 ctx, _ := context.RootContext()
35 var _ logging.Logger = ctx
36
37 // Make sure that logger.Manager can extract the appropriate management
38 // interface from a context.
39 nl := vlog.NewLogger("test")
40 ctx = context.WithLogger(ctx, nl)
41 manager = logger.Manager(ctx)
42 if _, ok := manager.(*vlog.Logger); !ok {
43 t.Errorf("failed to extract correct manager type")
44 }
Cosmos Nicolaou0e4e3922015-06-10 16:30:09 -070045}