Add accessor for the yq logger instance

Allow consumers of yqlib to customize the logger instance.

Closes #432

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>
This commit is contained in:
Carolyn Van Slyck 2020-12-30 10:38:20 -06:00
parent 1b887e23b3
commit dbcf6be8ff
No known key found for this signature in database
GPG Key ID: AEF5F64E6B9D8197
2 changed files with 15 additions and 0 deletions

View File

@ -11,6 +11,11 @@ import (
var log = logging.MustGetLogger("yq-lib") var log = logging.MustGetLogger("yq-lib")
// GetLogger returns the yq logger instance.
func GetLogger() *logging.Logger {
return log
}
type OperationType struct { type OperationType struct {
Type string Type string
NumArgs uint // number of arguments to the op NumArgs uint // number of arguments to the op

10
pkg/yqlib/lib_test.go Normal file
View File

@ -0,0 +1,10 @@
package yqlib
import "testing"
func TestGetLogger(t *testing.T) {
l := GetLogger()
if l != log {
t.Fatal("GetLogger should return the yq logger instance, not a copy")
}
}