Skip to content

Log stdout/stderr to server.log #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 30, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions browsermobproxy/server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import os
from subprocess import Popen, PIPE, STDOUT
import platform
import socket
import subprocess
import time
import platform

from client import Client


Expand Down Expand Up @@ -41,7 +42,10 @@ def start(self):
This will start the browsermob proxy and then wait until it can
interact with it
"""
self.process = Popen(self.command, stdout=PIPE, stderr=STDOUT)
self.log_file = open(os.path.abspath('server.log'), 'w')
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will overwrite the file each time you run it, I am happy with that, but is that what you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was intentional to prevent the file growing too large or becoming irrelevant.

self.process = subprocess.Popen(self.command,
stdout=self.log_file,
stderr=subprocess.STDOUT)
count = 0
while not self._is_listening():
time.sleep(0.5)
Expand All @@ -64,6 +68,8 @@ def stop(self):
# kill may not be available under windows environment
pass

self.log_file.close()

@property
def url(self):
"""
Expand Down