Merge pull request #9269 from chrisroberts/e-log-timestamp
Provide optional timestamp on log output
This commit is contained in:
commit
9be2651706
13
bin/vagrant
13
bin/vagrant
|
@ -52,6 +52,19 @@ if argv.include?("--debug")
|
|||
ENV["VAGRANT_LOG"] = "debug"
|
||||
end
|
||||
|
||||
# Enable log timestamps if requested
|
||||
if argv.include?("--timestamp")
|
||||
argv.delete("--timestamp")
|
||||
ENV["VAGRANT_LOG_TIMESTAMP"] = "1"
|
||||
end
|
||||
|
||||
# Convenience flag to enable debug with timestamps
|
||||
if argv.include?("--debug-timestamp")
|
||||
argv.delete("--debug-timestamp")
|
||||
ENV["VAGRANT_LOG"] = "debug"
|
||||
ENV["VAGRANT_LOG_TIMESTAMP"] = "1"
|
||||
end
|
||||
|
||||
# Stdout/stderr should not buffer output
|
||||
$stdout.sync = true
|
||||
$stderr.sync = true
|
||||
|
|
|
@ -41,6 +41,12 @@ if ENV["VAGRANT_LOG"] && ENV["VAGRANT_LOG"] != ""
|
|||
logger = Log4r::Logger.new("vagrant")
|
||||
logger.outputters = Log4r::Outputter.stderr
|
||||
logger.level = level
|
||||
if ENV["VAGRANT_LOG_TIMESTAMP"]
|
||||
Log4r::Outputter.stderr.formatter = Log4r::PatternFormatter.new(
|
||||
pattern: "%d [%5l] %m",
|
||||
date_pattern: "%F %T"
|
||||
)
|
||||
end
|
||||
logger = nil
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue