Skip to content

Commit

Permalink
replace std(out|err)log with conda.std(out|err).raw
Browse files Browse the repository at this point in the history
  • Loading branch information
mbargull committed Jun 22, 2017
1 parent 254f4bd commit 31e172e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 6 deletions.
2 changes: 1 addition & 1 deletion conda/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def init_loggers(context=None):
initialize_logging()
if context and context.json:
# Silence logging info to avoid interfering with JSON output
for logger in ('print', 'stdoutlog', 'stderrlog'):
for logger in ('print', 'conda.stdout.raw', 'conda.stderr.raw'):
getLogger(logger).setLevel(CRITICAL + 1)

if context and context.verbosity:
Expand Down
2 changes: 1 addition & 1 deletion conda/core/repodata.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
__all__ = ('RepoData',)

log = getLogger(__name__)
stderrlog = getLogger('stderrlog')
stderrlog = getLogger('conda.stderr.raw')

REPODATA_PICKLE_VERSION = 3
REPODATA_HEADER_RE = b'"(_etag|_mod|_cache_control)":[ ]?"(.*)"'
Expand Down
2 changes: 1 addition & 1 deletion conda/gateways/connection/adapters/s3.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ....common.url import url_to_s3_info

log = getLogger(__name__)
stderrlog = getLogger('stderrlog')
stderrlog = getLogger('conda.stderr.raw')


class S3Adapter(BaseAdapter):
Expand Down
2 changes: 1 addition & 1 deletion conda/gateways/disk/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from ...models.enums import FileMode, LinkType

log = getLogger(__name__)
stdoutlog = getLogger('stdoutlog')
stdoutlog = getLogger('conda.stdout.raw')

mkdir_p = mkdir_p # in __init__.py to help with circular imports

Expand Down
22 changes: 22 additions & 0 deletions conda/gateways/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ def stream(self):
return getattr(sys, self._sys_stream)


class RawFormatter(Formatter):
def format(self, record):
return record.msg


# Don't use initialize_logging/initialize_root_logger/set_conda_log_level in
# cli.python_api! There we want the user to have control over their logging,
# e.g., using their own levels, handlers, formatters and propagation settings.
Expand Down Expand Up @@ -88,6 +93,23 @@ def initialize_std_loggers():
stderr.addFilter(TokenURLFilter())
stderr.propagate = False

raw_formatter = RawFormatter()
stdout_raw = getLogger('conda.stdout.raw')
stdout_raw.setLevel(DEBUG)
stdout_raw_handler = StdStreamHandler('stdout', terminator='')
stdout_raw_handler.setLevel(DEBUG)
stdout_raw_handler.setFormatter(raw_formatter)
stdout_raw.addHandler(stdout_raw_handler)
stdout_raw.propagate = False

stderr_raw = getLogger('conda.stderr.raw')
stderr_raw.setLevel(DEBUG)
stderr_raw_handler = StdStreamHandler('stderr', terminator='')
stderr_raw_handler.setLevel(DEBUG)
stderr_raw_handler.setFormatter(raw_formatter)
stderr_raw.addHandler(stderr_raw_handler)
stderr_raw.propagate = False


def initialize_root_logger(level=ERROR):
attach_stderr_handler(level)
Expand Down
2 changes: 1 addition & 1 deletion conda/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
You can also use: $ conda clean --lock
"""

stdoutlog = logging.getLogger('stdoutlog')
log = logging.getLogger(__name__)
stdoutlog = logging.getLogger('conda.stdout.raw')

def touch(file_name, times=None):
""" Touch function like touch in Unix shell
Expand Down
2 changes: 1 addition & 1 deletion conda/resolve.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .models.version import normalized_version

log = logging.getLogger(__name__)
stdoutlog = logging.getLogger('stdoutlog')
stdoutlog = logging.getLogger('conda.stdout.raw')


# used in conda build
Expand Down

0 comments on commit 31e172e

Please sign in to comment.