Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: build/android/pylib/utils/logging_utils.py

Issue 875083002: [Android] Provide a logging suppressing context manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import contextlib
6 import logging
7
8 @contextlib.contextmanager
9 def SuppressLogging(level=logging.ERROR):
jbudorick 2015/01/26 16:07:32 My only comment on this is that handling levels as
10 """Momentarilly suppress logging events from all loggers.
11
12 TODO(jbudorick): This is not thread safe. Log events from other threads might
13 also inadvertently dissapear.
14
15 Example:
16
17 with logging_utils.SuppressLogging():
18 # all but CRITICAL logging messages are suppressed
19 logging.info('just doing some thing') # not shown
20 logging.critical('something really bad happened') # still shown
21
22 Args:
23 level: logging events with this or lower levels are suppressed.
24 """
25 logging.disable(level)
26 yield
27 logging.disable(logging.NOTSET)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698