blob: d2d9f0ef8c0c6169363252f5cd1e6c14f5f66cd5 [file] [log] [blame]
Matteo Scandolo2ba00d32020-01-16 17:33:03 -08001/*
2 * Portions copyright 2019-present Open Networking Foundation
3 * Original copyright 2019-present Ciena Corporation
4 *
5 * Licensed under the Apache License, Version 2.0 (the"github.com/stretchr/testify/assert" "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17package common
18
19/*
20 * This file has common code that is imported for all test cases, but
21 * is not built into production binaries.
22 */
23
24import (
25 "github.com/opencord/voltha-lib-go/v3/pkg/log"
26)
27
28const (
29 /*
30 * This sets the LogLevel of the Voltha logger. It's pinned to FatalLevel here, as we
31 * generally don't want to see logger output, even when running go test in verbose
32 * mode. Even "Error" level messages are expected to be output by some unit tests.
33 *
34 * If you are developing a unit test, and experiencing problems or wish additional
35 * debugging from Voltha, then changing this constant to log.DebugLevel may be
36 * useful.
37 */
38
39 VOLTHA_LOGLEVEL = log.FatalLevel
40)
41
42// Unit test initialization. This init() function will be run once for all unit tests in afrouter
43func init() {
44 // Logger must be configured or bad things happen
45 _, err := log.SetDefaultLogger(log.JSON, VOLTHA_LOGLEVEL, log.Fields{"instanceId": 1})
46 if err != nil {
47 panic(err)
48 }
49
50 _, err = log.AddPackage(log.JSON, VOLTHA_LOGLEVEL, nil)
51 if err != nil {
52 panic(err)
53 }
54}