OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 2 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
3 # for details. All rights reserved. Use of this source code is governed by a | 3 # for details. All rights reserved. Use of this source code is governed by a |
4 # BSD-style license that can be found in the LICENSE file. | 4 # BSD-style license that can be found in the LICENSE file. |
5 | 5 |
6 """Templating to help generate structured text.""" | 6 """Templating to help generate structured text.""" |
7 | 7 |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 import subprocess | 10 import subprocess |
11 import time | 11 import time |
12 import emitter | 12 import emitter |
13 import logging | 13 import logging |
14 | 14 |
15 _logger = logging.getLogger('multiemitter') | 15 _logger = logging.getLogger('multiemitter') |
16 | 16 |
17 class MultiEmitter(object): | 17 class MultiEmitter(object): |
18 """A set of Emitters that write to different files. | 18 """A set of Emitters that write to different files. |
19 | 19 |
20 Each entry has a key. | 20 Each entry has a key. |
21 | 21 |
22 file --> emitter | 22 file --> emitter |
23 key --> emitter | 23 key --> emitter |
24 | 24 |
25 """ | 25 """ |
26 | 26 |
27 def __init__(self): | 27 def __init__(self, logging_level=logging.WARNING): |
28 self._key_to_emitter = {} # key -> Emitter | 28 self._key_to_emitter = {} # key -> Emitter |
29 self._filename_to_emitter = {} # filename -> Emitter | 29 self._filename_to_emitter = {} # filename -> Emitter |
30 | 30 |
| 31 _logger.setLevel(logging_level) |
| 32 |
31 | 33 |
32 def FileEmitter(self, filename, key=None): | 34 def FileEmitter(self, filename, key=None): |
33 """Creates an emitter for writing to a file. | 35 """Creates an emitter for writing to a file. |
34 | 36 |
35 When this MultiEmitter is flushed, the contents of the emitter are written | 37 When this MultiEmitter is flushed, the contents of the emitter are written |
36 to the file. | 38 to the file. |
37 | 39 |
38 Arguments: | 40 Arguments: |
39 filename: a string, the path name of the file | 41 filename: a string, the path name of the file |
40 key: provides an access key to retrieve the emitter. | 42 key: provides an access key to retrieve the emitter. |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 110 |
109 if sys.platform == 'win32': | 111 if sys.platform == 'win32': |
110 handle_file = r'E:\handle.exe' | 112 handle_file = r'E:\handle.exe' |
111 if os.path.exists(handle_file): | 113 if os.path.exists(handle_file): |
112 _logger.info('Running handle.exe for debugging purposes') | 114 _logger.info('Running handle.exe for debugging purposes') |
113 subprocess.call([handle_file, '-a', r'E:\b\build\slave']) | 115 subprocess.call([handle_file, '-a', r'E:\b\build\slave']) |
114 else: | 116 else: |
115 _logger.info("Couldn't find %s. Not printing open handles." | 117 _logger.info("Couldn't find %s. Not printing open handles." |
116 % handle_file) | 118 % handle_file) |
117 raise error | 119 raise error |
OLD | NEW |