Log to a file by default, unless debugging
By default, log paunch to /var/log/paunch.log. Related-Bug: #1799182 Change-Id: Ib0685eb72becb867452bef17f17ab8e3d5b7d931 Signed-off-by: Bogdan Dobrelya <bdobreli@redhat.com>
This commit is contained in:
parent
7bb9121ef8
commit
791766596c
|
@ -20,6 +20,9 @@ import yaml
|
|||
|
||||
import paunch
|
||||
|
||||
from paunch import constants
|
||||
from paunch import utils
|
||||
|
||||
|
||||
class Apply(command.Command):
|
||||
|
||||
|
@ -69,8 +72,9 @@ class Apply(command.Command):
|
|||
# takes 1, or 2 if --verbose, or 4 - 5 if --debug
|
||||
log_level = (self.app_args.verbose_level +
|
||||
int(self.app_args.debug) * 3)
|
||||
self.log = paunch.utils.common.configure_logging(
|
||||
__name__, log_level, self.app_args.log_file)
|
||||
log_file = self.app_args.log_file or constants.LOG_FILE
|
||||
self.log = utils.common.configure_logging(
|
||||
__name__, log_level, log_file)
|
||||
labels = collections.OrderedDict()
|
||||
for l in parsed_args.labels:
|
||||
k, v = l.split(('='), 1)
|
||||
|
@ -86,7 +90,7 @@ class Apply(command.Command):
|
|||
labels=labels,
|
||||
default_runtime=parsed_args.default_runtime,
|
||||
log_level=log_level,
|
||||
log_file=self.app_args.log_file
|
||||
log_file=log_file
|
||||
)
|
||||
|
||||
return rc
|
||||
|
@ -118,13 +122,14 @@ class Cleanup(command.Command):
|
|||
# takes 1, or 2 if --verbose, or 4 - 5 if --debug
|
||||
log_level = (self.app_args.verbose_level +
|
||||
int(self.app_args.debug) * 3)
|
||||
self.log = paunch.utils.common.configure_logging(
|
||||
__name__, log_level, self.app_args.log_file)
|
||||
log_file = self.app_args.log_file or constants.LOG_FILE
|
||||
self.log = utils.common.configure_logging(
|
||||
__name__, log_level, log_file)
|
||||
paunch.cleanup(
|
||||
parsed_args.config_id,
|
||||
managed_by=parsed_args.managed_by,
|
||||
log_level=log_level,
|
||||
log_file=self.app_args.log_file
|
||||
log_file=log_file
|
||||
)
|
||||
|
||||
|
||||
|
@ -153,13 +158,14 @@ class Delete(command.Command):
|
|||
# takes 1, or 2 if --verbose, or 4 - 5 if --debug
|
||||
log_level = (self.app_args.verbose_level +
|
||||
int(self.app_args.debug) * 3)
|
||||
self.log = paunch.utils.common.configure_logging(
|
||||
__name__, log_level, self.app_args.log_file)
|
||||
log_file = self.app_args.log_file or constants.LOG_FILE
|
||||
self.log = utils.common.configure_logging(
|
||||
__name__, log_level, log_file)
|
||||
paunch.delete(
|
||||
parsed_args.config_id,
|
||||
parsed_args.managed_by,
|
||||
log_level=log_level,
|
||||
log_file=self.app_args.log_file
|
||||
log_file=log_file
|
||||
)
|
||||
|
||||
|
||||
|
@ -251,8 +257,10 @@ class Debug(command.Command):
|
|||
# takes 1, or 2 if --verbose, or 4 - 5 if --debug
|
||||
log_level = (self.app_args.verbose_level +
|
||||
int(self.app_args.debug) * 3)
|
||||
self.log = paunch.utils.common.configure_logging(
|
||||
__name__, log_level, self.app_args.log_file)
|
||||
# Only log to a file if explicitely set via CLI args
|
||||
log_file = self.app_args.log_file
|
||||
self.log = utils.common.configure_logging(
|
||||
__name__, log_level, log_file)
|
||||
labels = collections.OrderedDict()
|
||||
for l in parsed_args.labels:
|
||||
k, v = l.split(('='), 1)
|
||||
|
@ -295,7 +303,7 @@ class Debug(command.Command):
|
|||
parsed_args.managed_by,
|
||||
labels=labels,
|
||||
log_level=log_level,
|
||||
log_file=self.app_args.log_file
|
||||
log_file=log_file
|
||||
)
|
||||
|
||||
|
||||
|
@ -318,12 +326,13 @@ class List(lister.Lister):
|
|||
# takes 1, or 2 if --verbose, or 4 - 5 if --debug
|
||||
log_level = (self.app_args.verbose_level +
|
||||
int(self.app_args.debug) * 3)
|
||||
self.log = paunch.utils.common.configure_logging(
|
||||
__name__, log_level, self.app_args.log_file)
|
||||
log_file = self.app_args.log_file or constants.LOG_FILE
|
||||
self.log = utils.common.configure_logging(
|
||||
__name__, log_level, log_file)
|
||||
configs = paunch.list(
|
||||
parsed_args.managed_by,
|
||||
log_level=log_level,
|
||||
log_file=self.app_args.log_file
|
||||
log_file=log_file
|
||||
)
|
||||
columns = [
|
||||
'config',
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
# Copyright 2018 Red Hat, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
#
|
||||
|
||||
LOG_FILE = '/var/log/paunch.log'
|
Loading…
Reference in New Issue