OLD | NEW |
1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Utilities for logging. | 5 """Utilities for logging. |
6 | 6 |
7 Example usage: | 7 Example usage: |
8 | 8 |
9 .. code-block:: python | 9 .. code-block:: python |
10 | 10 |
(...skipping 23 matching lines...) Expand all Loading... |
34 import logging.handlers | 34 import logging.handlers |
35 import os | 35 import os |
36 import re | 36 import re |
37 import socket | 37 import socket |
38 import sys | 38 import sys |
39 import tempfile | 39 import tempfile |
40 import textwrap | 40 import textwrap |
41 | 41 |
42 import pytz | 42 import pytz |
43 | 43 |
44 from infra_libs.ts_mon import metrics | 44 from infra_libs.ts_mon.metrics import CumulativeMetric |
45 | 45 |
46 log_metric = metrics.CumulativeMetric('proc/log_lines') | 46 log_metric = CumulativeMetric('proc/log_lines') |
47 | 47 |
48 if sys.platform.startswith('win'): # pragma: no cover | 48 if sys.platform.startswith('win'): # pragma: no cover |
49 DEFAULT_LOG_DIRECTORIES = os.pathsep.join([ | 49 DEFAULT_LOG_DIRECTORIES = os.pathsep.join([ |
50 'E:\\chrome-infra-logs', | 50 'E:\\chrome-infra-logs', |
51 'C:\\chrome-infra-logs', | 51 'C:\\chrome-infra-logs', |
52 ]) | 52 ]) |
53 else: | 53 else: |
54 DEFAULT_LOG_DIRECTORIES = '/var/log/chrome-infra' | 54 DEFAULT_LOG_DIRECTORIES = '/var/log/chrome-infra' |
55 | 55 |
56 | 56 |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
265 for level in (logging.INFO, logging.WARNING, logging.ERROR): | 265 for level in (logging.INFO, logging.WARNING, logging.ERROR): |
266 add_handler( | 266 add_handler( |
267 logger, | 267 logger, |
268 handler=logging.handlers.RotatingFileHandler( | 268 handler=logging.handlers.RotatingFileHandler( |
269 filename=os.path.join( | 269 filename=os.path.join( |
270 logs_directory, pattern % logging.getLevelName(level)), | 270 logs_directory, pattern % logging.getLevelName(level)), |
271 maxBytes=10 * 1024 * 1024, | 271 maxBytes=10 * 1024 * 1024, |
272 backupCount=10, | 272 backupCount=10, |
273 delay=True), | 273 delay=True), |
274 level=level) | 274 level=level) |
OLD | NEW |