diff --git a/testing/mozbase/mozlog/mozlog/structured/commandline.py b/testing/mozbase/mozlog/mozlog/structured/commandline.py index fc9e68bb0caf..d4a993febe57 100644 --- a/testing/mozbase/mozlog/mozlog/structured/commandline.py +++ b/testing/mozbase/mozlog/mozlog/structured/commandline.py @@ -3,6 +3,7 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import sys +import os import optparse from collections import defaultdict @@ -59,8 +60,11 @@ fmt_options = { def log_file(name): if name == "-": return sys.stdout - else: - return open(name, "w") + # ensure we have a correct dirpath by using realpath + dirpath = os.path.dirname(os.path.realpath(name)) + if not os.path.exists(dirpath): + os.makedirs(dirpath) + return open(name, "w") def add_logging_group(parser, include_formatters=None):