Browse Source

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>
(cherry picked from commit 791766596c)
changes/38/702438/2
Bogdan Dobrelya 1 year ago
parent
commit
1c590fc76d
2 changed files with 40 additions and 15 deletions
  1. +24
    -15
      paunch/cmd.py
  2. +16
    -0
      paunch/constants.py

+ 24
- 15
paunch/cmd.py View File

@@ -20,6 +20,9 @@ import yaml

import paunch

from paunch import constants
from paunch import utils


class Apply(command.Command):

@@ -62,8 +65,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)
@@ -78,7 +82,7 @@ class Apply(command.Command):
managed_by='paunch',
labels=labels,
log_level=log_level,
log_file=self.app_args.log_file
log_file=log_file
)

return rc
@@ -110,13 +114,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
)


@@ -145,13 +150,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
)


@@ -242,8 +248,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)
@@ -286,7 +294,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
)


@@ -309,12 +317,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',

+ 16
- 0
paunch/constants.py View File

@@ -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…
Cancel
Save