blob: 2a4da8e1dab7a4407c30bb38a80f13b175c637da [file] [log] [blame]
Adrià Vilanova Martínezf19ea432024-01-23 20:20:52 +01001# Copyright 2022 The Chromium Authors
Adrià Vilanova Martínez9f9ade52022-10-10 23:20:11 +02002# 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
6from __future__ import print_function
7from __future__ import division
8from __future__ import absolute_import
9
10import google.cloud.logging
11
12import settings
13
14
15def 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)