Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding logger & display commands executed with --debug #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/gitchangelog/gitchangelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from __future__ import absolute_import

import locale
import logging
import re
import os
import os.path
Expand Down Expand Up @@ -34,6 +35,7 @@
__version__ = "%%version%%" ## replaced by autogen.sh

DEBUG = None
LOGGER = logging.getLogger(__name__)


##
Expand Down Expand Up @@ -643,7 +645,7 @@ def __init__(self, command, env=None, encoding=_preferred_encoding):


def cmd(command, env=None, shell=True):

LOGGER.debug('Executing: %s', ' '.join(command))
p = Popen(command, shell=shell,
stdin=PIPE, stdout=PIPE, stderr=PIPE,
close_fds=PLT_CFG['close_fds'], env=env,
Expand Down Expand Up @@ -1724,7 +1726,8 @@ def parse_cmd_line(usage, description, epilog, exname, version):
action="version", version=version)

parser.add_argument('-d', '--debug',
help="Enable debug mode (show full tracebacks).",
help="Enable debug mode (show commands executed"
" & full tracebacks).",
action="store_true", dest="debug")
parser.add_argument('revlist', nargs='*', action="store", default=[])

Expand Down Expand Up @@ -1887,6 +1890,7 @@ def main():

debug_varname = "DEBUG_%s" % basename.upper()
DEBUG = os.environ.get(debug_varname, False)
logging.basicConfig(level=logging.DEBUG if DEBUG else logging.INFO)

i = lambda x: x % {'exname': basename}

Expand Down