Skip to content

Commit

Permalink
Add a modifier for GCP cloud logging
Browse files Browse the repository at this point in the history
This commit adds a modifier which will upload logs into Google Cloud
Platform's Cloud Logging.
  • Loading branch information
douglasjacobsen committed Nov 9, 2024
1 parent cd68996 commit be6c9d8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions var/ramble/repos/builtin/modifiers/gcp-cloud-logging/modifier.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright 2022-2024 The Ramble Authors
#
# Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
# https://www.apache.org/licenses/LICENSE-2.0> or the MIT license
# <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
# option. This file may not be copied, modified, or distributed
# except according to those terms.

from ramble.modkit import * # noqa: F403


class GcpCloudLogging(BasicModifier):
"""Upload experiment logs to Google Cloud Platform Cloud Logging.
https://cloud.google.com/logging?e=48754805&hl=en
"""

name = "gcp-cloud-logging"

tags("info")

maintainers("douglasjacobsen")

mode("standard", description="Standard execution mode")

default_mode("standard")

register_builtin(
"start_cloud_logger", required=True, injection_method="prepend"
)

def start_cloud_logger(self):
return [
"tail -f {log_file} | logger -t {experiment_namespace} &",
"export LOGGER_PID=$!",
]

register_builtin(
"kill_cloud_logger", required=True, injection_method="append"
)

def kill_cloud_logger(self):
return ["kill -9 $LOGGER_PID"]

0 comments on commit be6c9d8

Please sign in to comment.