Add accessor for the yq logger instance (#1013)

Allow consumers of yqlib to customize the logger instance.

Closes #432

Signed-off-by: Carolyn Van Slyck <me@carolynvanslyck.com>

Co-authored-by: Carolyn Van Slyck <me@carolynvanslyck.com>
Co-authored-by: Rob Ferguson <robert.j.ferguson@nasa.gov>
This commit is contained in:
Rob Ferguson 2021-11-29 17:51:49 -06:00 committed by GitHub
parent 176fec639d
commit d41b44dc42
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,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")
}
}