Skip to content

Commit

Permalink
Add a setting for debug logging
Browse files Browse the repository at this point in the history
This is very primitive logging, with no control over output filenames,
paths, or log rotation.  As such, it is only meant for debugging.

To enable, set debug_logs: true in the pipeline config.

Issue #12

Change-Id: I16696b5cea54579b921ff8186c944e8e5a5939fc
  • Loading branch information
joeyparrish committed Oct 4, 2019
1 parent f8c4bb8 commit 67ac9e4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 3 deletions.
4 changes: 4 additions & 0 deletions streamer/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@
# If true, reduce the level of output. Only errors will be shown in quiet
# mode.
'quiet': False,
# If true, output simple log files from each node. No control is given over
# log filenames. Logs are written to the current working directory. We do
# not yet support log rotation. This is meant only for debugging.
'debug_logs': False,

'transcoder': {
# A list of resolutions to encode.
Expand Down
12 changes: 11 additions & 1 deletion streamer/loop_input_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,15 @@ def start(self):
self._output_path,
]

self._process = self._create_process(args)
env = {}
if self._config.debug_logs:
# A safe version of the input path that we can put into a log filename.
sanitized_input = self._input_path.replace('/', '-').replace('\\', '-')
# Use this environment variable to turn on ffmpeg's logging. This is
# independent of the -loglevel switch above. The log file will have the
# input filename in it, in case there are multiple LoopInputNodes.
env['FFREPORT'] = 'file=LoopInputNode-{}.log:level=32'.format(
sanitized_input)

self._process = self._create_process(args, env)

11 changes: 10 additions & 1 deletion streamer/packager_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""A module that feeds information from two named pipes into shaka-packager."""

import os
import subprocess

from . import metadata
from . import node_base
Expand Down Expand Up @@ -124,8 +125,16 @@ def start(self):
if self._config.encryption['enable']:
args += self._setup_encryption()

self._process = self._create_process(args)
stdout = None
if self._config.debug_logs:
# Log by writing all Packager output to a file. Unlike the logging
# system in ffmpeg, this will stop any Packager output from getting to
# the screen.
stdout = open('PackagerNode.log', 'w')

self._process = self._create_process(args,
stderr=subprocess.STDOUT,
stdout=stdout)

def _create_text(self, dict, language):
# TODO: Format using text Metadata objects, which don't exist yet
Expand Down
2 changes: 2 additions & 0 deletions streamer/pipeline_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

MODE = 'streaming_mode'
QUIET = 'quiet'
DEBUG_LOGS = 'debug_logs'
TRANSCODER = 'transcoder'
PACKAGER = 'packager'
ENCRYPTION = 'encryption'
Expand All @@ -32,6 +33,7 @@ def __init__(self, user_config,
self.dict = user_config
self.mode = self.dict[MODE]
self.quiet = self.dict[QUIET]
self.debug_logs = self.dict[DEBUG_LOGS]
self.transcoder = self.dict[TRANSCODER]
self.packager = self.dict[PACKAGER]
self.encryption = self.packager[ENCRYPTION]
8 changes: 7 additions & 1 deletion streamer/transcoder_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,13 @@ def start(self):
args += map_args
args += self._encode_video(video, input)

self._process = self._create_process(args)
env = {}
if self._config.debug_logs:
# Use this environment variable to turn on ffmpeg's logging. This is
# independent of the -loglevel switch above.
env['FFREPORT'] = 'file=TranscoderNode.log:level=32'

self._process = self._create_process(args, env)

def _live_input(self, input_object):
args = []
Expand Down

0 comments on commit 67ac9e4

Please sign in to comment.