Add JSON as an option for log output (#1654)

* Add JSON as an option for log output

Signed-off-by: Donovan Carthew <donovan.carthew@gmail.com>
This commit is contained in:
carthewd
2019-07-30 16:29:34 -07:00
committed by KubeKween
parent 6188cdffb0
commit 22eca22ac8
11 changed files with 126 additions and 23 deletions
+4 -1
View File
@@ -70,6 +70,7 @@ type backupController struct {
defaultSnapshotLocations map[string]string
metrics *metrics.ServerMetrics
newBackupStore func(*velerov1api.BackupStorageLocation, persistence.ObjectStoreGetter, logrus.FieldLogger) (persistence.BackupStore, error)
formatFlag logging.Format
}
func NewBackupController(
@@ -86,6 +87,7 @@ func NewBackupController(
volumeSnapshotLocationInformer informers.VolumeSnapshotLocationInformer,
defaultSnapshotLocations map[string]string,
metrics *metrics.ServerMetrics,
formatFlag logging.Format,
) Interface {
c := &backupController{
genericController: newGenericController("backup", logger),
@@ -102,6 +104,7 @@ func NewBackupController(
snapshotLocationLister: volumeSnapshotLocationInformer.Lister(),
defaultSnapshotLocations: defaultSnapshotLocations,
metrics: metrics,
formatFlag: formatFlag,
newBackupStore: persistence.NewObjectBackupStore,
}
@@ -448,7 +451,7 @@ func (c *backupController) runBackup(backup *pkgbackup.Request) error {
// Log the backup to both a backup log file and to stdout. This will help see what happened if the upload of the
// backup log failed for whatever reason.
logger := logging.DefaultLogger(c.backupLogLevel)
logger := logging.DefaultLogger(c.backupLogLevel, c.formatFlag)
logger.Out = io.MultiWriter(os.Stdout, gzippedLogFile)
logCounter := logging.NewLogCounterHook()