Adrià Vilanova MartÃnez | 9f9ade5 | 2022-10-10 23:20:11 +0200 | [diff] [blame^] | 1 | # Copyright 2022 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 | """"Helper methods for structured logging.""" |
| 5 | |
| 6 | from __future__ import print_function |
| 7 | from __future__ import division |
| 8 | from __future__ import absolute_import |
| 9 | |
| 10 | import google.cloud.logging |
| 11 | |
| 12 | import settings |
| 13 | |
| 14 | |
| 15 | def log(struct): |
| 16 | if settings.local_mode or settings.unit_test_mode: |
| 17 | return |
| 18 | |
| 19 | logging_client = google.cloud.logging.Client() |
| 20 | logger = logging_client.logger('python') |
| 21 | logger.log_struct(struct) |