Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1638)

Unified Diff: appengine/gce-backend/agent/agent.py

Issue 2991423002: Use journald for logging with systemd (Closed)
Patch Set: Update class name Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/gce-backend/agent/agent.py
diff --git a/appengine/gce-backend/agent/agent.py b/appengine/gce-backend/agent/agent.py
index ef52a8d5ae00f3081bb4f31b5eb61f54c710011a..4b21655521512f08912e58a4aa5fe2cd2aecb419 100755
--- a/appengine/gce-backend/agent/agent.py
+++ b/appengine/gce-backend/agent/agent.py
@@ -342,13 +342,23 @@ class SystemdAgent(Agent):
AGENT_AUTOSTART_TEMPLATE = os.path.join(
THIS_DIR, 'machine-provider-agent.service.tmpl')
AGENT_AUTOSTART_PATH = '/etc/systemd/system/machine-provider-agent.service'
- LOGS_DIR = '/var/log/messages/machine-provider-agent'
+ LOGS_DIR = '/var/log/machine-provider-agent'
REBOOT_CMD = ('/sbin/shutdown', '-r', 'now')
SWARMING_AUTOSTART_TEMPLATE = os.path.join(
THIS_DIR, 'swarming-start-bot.service.tmpl')
SWARMING_AUTOSTART_PATH = '/etc/systemd/system/swarming-start-bot.service'
SWARMING_BOT_DIR = '/b/s'
+ def configure_logging(self):
+ """Sets up the logging."""
+ try:
+ from systemd.journal import JournalHandler
+ logger = logging.getLogger()
+ logger.setLevel(logging.DEBUG)
+ logger.addHandler(JournalHandler())
+ except ImportError:
+ super(Agent, self).configure_logging()
+
def start(self):
"""Starts the Machine Provider agent."""
subprocess.check_call(['systemctl', 'daemon-reload'])
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698