Add a prefix to the logger

This will make it easier to differentiate between airship log messages
and third-party log message (e.g. clusterctl)

Change-Id: I0b8a2fed58a6a673277f511267e2498c7e8d4c1b
This commit is contained in:
Ian Howell 2020-05-01 12:08:29 -05:00
parent 54d7b5f229
commit 07896b97c5
2 changed files with 3 additions and 3 deletions

View File

@ -22,7 +22,7 @@ import (
var (
debug = false
airshipLog = log.New(os.Stderr, "", log.LstdFlags)
airshipLog = log.New(os.Stderr, "[airshipctl] ", log.LstdFlags)
)
// Init initializes settings related to logging

View File

@ -25,9 +25,9 @@ import (
"opendev.org/airship/airshipctl/pkg/log"
)
var logFormatRegex = regexp.MustCompile(`^\d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*`)
var logFormatRegex = regexp.MustCompile(`^\[airshipctl\] \d{4}/\d{2}/\d{2} \d{2}:\d{2}:\d{2} .*`)
const prefixLength = len("2001/02/03 16:05:06 ")
const prefixLength = len("[airshipctl] 2001/02/03 16:05:06 ")
func TestLoggingPrintf(t *testing.T) {
assert := assert.New(t)