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

--HG--
extra : rebase_source : f895f820c97796573a665ecc28358931700b0c43
This commit is contained in:
Julien Pagès 2015-03-06 06:17:00 -05:00
Родитель ca5799606e
Коммит 5bf31af53c
1 изменённых файлов: 6 добавлений и 2 удалений

Просмотреть файл

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