Bug 1132409 - [mozlog] Create directories for log specified on the command line if not present. r=jgraham

This commit is contained in:
Julien Pagès 2015-03-06 06:17:00 -05:00
parent 55ed4fbd1d
commit 515e07407e

View File

@ -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):