| 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.common.metrics import CumulativeMetric | 44 from infra_libs.ts_mon.common import metrics |
| 45 | 45 |
| 46 log_metric = CumulativeMetric( | 46 log_metric = metrics.CumulativeMetric( |
| 47 'proc/log_lines', description="Number of log lines, per severity level.") | 47 'proc/log_lines', |
| 48 'Number of log lines, per severity level.', |
| 49 [metrics.StringField('level')]) |
| 48 | 50 |
| 49 if sys.platform.startswith('win'): # pragma: no cover | 51 if sys.platform.startswith('win'): # pragma: no cover |
| 50 DEFAULT_LOG_DIRECTORIES = os.pathsep.join([ | 52 DEFAULT_LOG_DIRECTORIES = os.pathsep.join([ |
| 51 'E:\\chrome-infra-logs', | 53 'E:\\chrome-infra-logs', |
| 52 'C:\\chrome-infra-logs', | 54 'C:\\chrome-infra-logs', |
| 53 ]) | 55 ]) |
| 54 else: | 56 else: |
| 55 DEFAULT_LOG_DIRECTORIES = '/var/log/chrome-infra' | 57 DEFAULT_LOG_DIRECTORIES = '/var/log/chrome-infra' |
| 56 | 58 |
| 57 | 59 |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 for level in file_levels: | 288 for level in file_levels: |
| 287 add_handler( | 289 add_handler( |
| 288 logger, | 290 logger, |
| 289 handler=logging.handlers.RotatingFileHandler( | 291 handler=logging.handlers.RotatingFileHandler( |
| 290 filename=os.path.join( | 292 filename=os.path.join( |
| 291 logs_directory, pattern % logging.getLevelName(level)), | 293 logs_directory, pattern % logging.getLevelName(level)), |
| 292 maxBytes=10 * 1024 * 1024, | 294 maxBytes=10 * 1024 * 1024, |
| 293 backupCount=10, | 295 backupCount=10, |
| 294 delay=True), | 296 delay=True), |
| 295 level=level) | 297 level=level) |
| OLD | NEW |