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,7 +60,10 @@ fmt_options = {
def log_file(name):
if name == "-":
return sys.stdout
else:
# 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")