When this parameter is set, `args.logfd` (the log file descriptor) gets set to `sys.stdout`, so all logging gets directly sent to the active pmbootstrap session, and not to a log file. This will be used for Travis jobs, because they get killed after 10 minutes without any output (and builds may take longer).
This commit is contained in:
parent
6c368f8ced
commit
025d646e47
|
@ -18,6 +18,7 @@ along with pmbootstrap. If not, see <http://www.gnu.org/licenses/>.
|
|||
"""
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
class log_handler(logging.StreamHandler):
|
||||
|
@ -31,7 +32,9 @@ class log_handler(logging.StreamHandler):
|
|||
msg = self.format(record)
|
||||
|
||||
# INFO or higher: Write to stdout
|
||||
if not self._args.quiet and record.levelno >= logging.INFO:
|
||||
if (not self._args.details_to_stdout and
|
||||
not self._args.quiet and
|
||||
record.levelno >= logging.INFO):
|
||||
stream = self.stream
|
||||
stream.write(msg)
|
||||
stream.write(self.terminator)
|
||||
|
@ -71,10 +74,15 @@ def init(args):
|
|||
Set log format and add the log file descriptor to args.logfd, add the
|
||||
verbose log level.
|
||||
"""
|
||||
# Open logfile
|
||||
# Create work folder (because usually the log file is in there)
|
||||
if not os.path.exists(args.work):
|
||||
os.makedirs(args.work)
|
||||
setattr(args, "logfd", open(args.log, "a+"))
|
||||
|
||||
# Open logfile
|
||||
if args.details_to_stdout:
|
||||
setattr(args, "logfd", sys.stdout)
|
||||
else:
|
||||
setattr(args, "logfd", open(args.log, "a+"))
|
||||
|
||||
# Set log format
|
||||
root_logger = logging.getLogger()
|
||||
|
|
|
@ -107,7 +107,12 @@ def arguments():
|
|||
" gets stored (chroots, caches, built packages)")
|
||||
|
||||
# Logging
|
||||
parser.add_argument("-l", "--log", dest="log", default=None)
|
||||
parser.add_argument("-l", "--log", dest="log", default=None,
|
||||
help="path to log file")
|
||||
parser.add_argument("--details-to-stdout", dest="details_to_stdout",
|
||||
help="print details (e.g. build output) to stdout,"
|
||||
" instead of writing to the log",
|
||||
action="store_true")
|
||||
parser.add_argument("-v", "--verbose", dest="verbose",
|
||||
action="store_true", help="write even more to the"
|
||||
" logfiles (this may reduce performance)")
|
||||
|
|
Loading…
Reference in New Issue