vagrant-timer 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 87fbf281d87ceeca242ff866a717be14eb3e2123
4
- data.tar.gz: 6a52c747ff2ff136c6f4ade645c088b96b05abcf
3
+ metadata.gz: e84310e340e24c953d979083be12b36616dd327f
4
+ data.tar.gz: 086739cb073cfbaf79865d5decfcbac7e5f97790
5
5
  SHA512:
6
- metadata.gz: c8400614890a452941a751ffedb1e8ba68b886c00c81d70fbd6d99f77e7c5f215d0259de2fc293c6c3e7d7d2bfca1224e9ae5bb212240ce3b3e623c2b98ec8b0
7
- data.tar.gz: 5a25f99380cc0682c34cb15aab0b5fa4451ea32da0db5d8c88c008e58082c770edeebdb125eb0805d633b056f5aa5b1552c625c4700de5c5651d0300a94aa064
6
+ metadata.gz: 54423733364d6f9752b735fb4c13af53e15d03e8950794254ba721c7dc8034f3f8af6dfadee71abacfc83092651d01ce78677c8ff7a25bdb8baec78625b38a37
7
+ data.tar.gz: 7a6bea1057692f89544b490611ffaa7166edb4942e0e4242ee4ce83a1b88aafd02799bae68c96cc8d01606eb14f3fe2cf634071dd1b1bb2e98c1dbb59445f5e9
data/README.md CHANGED
@@ -42,6 +42,11 @@ Set the environment variable `VAGRANT_TIMER_LOG` to a filename to record the
42
42
  durations of all executed vagrant actions. The log messages will be appended
43
43
  to the specified file. If the variable is unset, no messages will be logged.
44
44
 
45
+ The log file name may include formatting variables understood by `strftime`.
46
+ These will be interpolated with the start time of the event. For example, if
47
+ `VAGRANT_TIMER_LOG = .vagrant-logs/%Y-%m-%d.log`, then an event that happens on
48
+ July 21st, 2016 will end up in the log file `.vagrant-logs/2016-07-21.log`.
49
+
45
50
  ## Development
46
51
 
47
52
  After checking out the repo, run `bin/setup` to install dependencies. You can
@@ -1,5 +1,5 @@
1
1
  module Vagrant
2
2
  module Timer
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
data/lib/vagrant/timer.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "vagrant/timer/version"
2
+ require "fileutils"
2
3
 
3
4
  require "vagrant"
4
5
 
@@ -10,6 +11,9 @@ module Vagrant
10
11
  A plugin to capture timing information from a vagrant run.
11
12
  Set the environment variable VAGRANT_TIMER_LOG to the file to
12
13
  log timing data to.
14
+
15
+ VAGRANT_TIMER_LOG can have strftime variables in it, which
16
+ will be replaced by the time that the vagrant step started.
13
17
  DESC
14
18
 
15
19
  action_hook("timer") do |hook|
@@ -43,9 +47,9 @@ module Vagrant
43
47
  :vagrant_version => Vagrant::VERSION,
44
48
  :box => box,
45
49
  :action_name => env[:action_name],
46
- :initialized_at => @init_time,
47
- :started_at => @start_call,
48
- :ended_at => @end_call,
50
+ :initialized_at => @init_time.to_s,
51
+ :started_at => @start_call.to_s,
52
+ :ended_at => @end_call.to_s,
49
53
  :init_duration => @start_call - @init_time,
50
54
  :call_duration => @end_call - @start_call,
51
55
  }
@@ -56,8 +60,14 @@ module Vagrant
56
60
  end
57
61
 
58
62
  if !ENV['VAGRANT_TIMER_LOG'].nil?
63
+ log_path = @init_time.strftime(ENV['VAGRANT_TIMER_LOG'])
64
+
65
+ if !File::exist?(File::dirname(log_path))
66
+ FileUtils.mkdir_p(File::dirname(log_path))
67
+ end
68
+
59
69
  begin
60
- File.open(ENV['VAGRANT_TIMER_LOG'], 'a') do |file|
70
+ File.open(log_path, 'a') do |file|
61
71
  file.write(event.to_json + "\n")
62
72
  end
63
73
  rescue SystemCallError => err
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-timer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Calen Pennington
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-11 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake