vagrantup 0.7.8 → 0.8.0

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.
Files changed (80) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +35 -0
  3. data/Gemfile +1 -7
  4. data/Rakefile +0 -11
  5. data/bin/vagrant +4 -0
  6. data/config/default.rb +1 -2
  7. data/lib/vagrant.rb +7 -5
  8. data/lib/vagrant/action.rb +5 -1
  9. data/lib/vagrant/action/builtin.rb +4 -1
  10. data/lib/vagrant/action/general/package.rb +6 -2
  11. data/lib/vagrant/action/vm.rb +2 -0
  12. data/lib/vagrant/action/vm/clear_forwarded_ports.rb +9 -22
  13. data/lib/vagrant/action/vm/clear_shared_folders.rb +9 -14
  14. data/lib/vagrant/action/vm/customize.rb +9 -4
  15. data/lib/vagrant/action/vm/forward_ports.rb +10 -11
  16. data/lib/vagrant/action/vm/match_mac_address.rb +8 -3
  17. data/lib/vagrant/action/vm/modify.rb +37 -0
  18. data/lib/vagrant/action/vm/network.rb +9 -2
  19. data/lib/vagrant/action/vm/provision.rb +10 -17
  20. data/lib/vagrant/action/vm/provisioner_cleanup.rb +26 -0
  21. data/lib/vagrant/action/vm/share_folders.rb +16 -8
  22. data/lib/vagrant/action/warden.rb +8 -2
  23. data/lib/vagrant/command/ssh.rb +4 -4
  24. data/lib/vagrant/command/ssh_config.rb +4 -2
  25. data/lib/vagrant/config/ssh.rb +3 -0
  26. data/lib/vagrant/config/vm.rb +16 -12
  27. data/lib/vagrant/downloaders/http.rb +2 -0
  28. data/lib/vagrant/environment.rb +136 -12
  29. data/lib/vagrant/errors.rb +15 -0
  30. data/lib/vagrant/provisioners.rb +1 -1
  31. data/lib/vagrant/provisioners/base.rb +4 -0
  32. data/lib/vagrant/provisioners/chef.rb +13 -11
  33. data/lib/vagrant/provisioners/{chef_server.rb → chef_client.rb} +5 -5
  34. data/lib/vagrant/provisioners/chef_solo.rb +48 -89
  35. data/lib/vagrant/provisioners/shell.rb +47 -12
  36. data/lib/vagrant/ssh.rb +61 -27
  37. data/lib/vagrant/systems.rb +1 -0
  38. data/lib/vagrant/systems/base.rb +1 -1
  39. data/lib/vagrant/systems/linux.rb +7 -9
  40. data/lib/vagrant/systems/redhat.rb +12 -4
  41. data/lib/vagrant/systems/solaris.rb +9 -4
  42. data/lib/vagrant/systems/suse.rb +9 -0
  43. data/lib/vagrant/ui.rb +12 -5
  44. data/lib/vagrant/util.rb +2 -2
  45. data/lib/vagrant/util/counter.rb +22 -0
  46. data/lib/vagrant/util/platform.rb +1 -2
  47. data/lib/vagrant/util/safe_exec.rb +28 -0
  48. data/lib/vagrant/version.rb +1 -1
  49. data/lib/vagrant/vm.rb +2 -0
  50. data/templates/chef_solo_solo.erb +4 -4
  51. data/templates/commands/init/Vagrantfile.erb +4 -0
  52. data/templates/locales/en.yml +31 -8
  53. data/templates/ssh_config.erb +6 -0
  54. data/test/test_helper.rb +5 -3
  55. data/test/vagrant/action/builder_test.rb +4 -0
  56. data/test/vagrant/action/vm/clear_forwarded_ports_test.rb +18 -38
  57. data/test/vagrant/action/vm/clear_shared_folders_test.rb +7 -16
  58. data/test/vagrant/action/vm/customize_test.rb +12 -5
  59. data/test/vagrant/action/vm/forward_ports_test.rb +12 -7
  60. data/test/vagrant/action/vm/match_mac_address_test.rb +5 -1
  61. data/test/vagrant/action/vm/modify_test.rb +38 -0
  62. data/test/vagrant/action/vm/provision_test.rb +13 -38
  63. data/test/vagrant/action/vm/provisioner_cleanup_test.rb +56 -0
  64. data/test/vagrant/action/vm/share_folders_test.rb +10 -5
  65. data/test/vagrant/action/warden_test.rb +13 -7
  66. data/test/vagrant/config/vm_test.rb +0 -22
  67. data/test/vagrant/downloaders/http_test.rb +2 -0
  68. data/test/vagrant/environment_test.rb +110 -20
  69. data/test/vagrant/provisioners/{chef_server_test.rb → chef_client_test.rb} +2 -2
  70. data/test/vagrant/provisioners/chef_solo_test.rb +16 -173
  71. data/test/vagrant/ssh_test.rb +8 -43
  72. data/test/vagrant/systems/linux_test.rb +9 -19
  73. data/test/vagrant/util/counter_test.rb +29 -0
  74. data/test/vagrant/util/platform_test.rb +2 -2
  75. data/vagrant.gemspec +1 -2
  76. metadata +13 -23
  77. data/lib/vagrant/util/plain_logger.rb +0 -25
  78. data/lib/vagrant/util/resource_logger.rb +0 -63
  79. data/test/vagrant/util/plain_logger_test.rb +0 -17
  80. data/test/vagrant/util/resource_logger_test.rb +0 -78
@@ -20,10 +20,8 @@ class SshTest < Test::Unit::TestCase
20
20
  mock_ssh
21
21
  @ssh.stubs(:check_key_permissions)
22
22
  @ssh.stubs(:port).returns(2222)
23
- Kernel.stubs(:exec)
23
+ @ssh.stubs(:safe_exec)
24
24
  Kernel.stubs(:system).returns(true)
25
-
26
- Vagrant::Util::Platform.stubs(:leopard?).returns(false)
27
25
  end
28
26
 
29
27
  should "raise an exception if SSH is not found" do
@@ -41,7 +39,7 @@ class SshTest < Test::Unit::TestCase
41
39
  should "check key permissions prior to exec" do
42
40
  exec_seq = sequence("exec_seq")
43
41
  @ssh.expects(:check_key_permissions).with(@env.config.ssh.private_key_path).once.in_sequence(exec_seq)
44
- Kernel.expects(:exec).in_sequence(exec_seq)
42
+ @ssh.expects(:safe_exec).in_sequence(exec_seq)
45
43
  @ssh.connect
46
44
  end
47
45
 
@@ -81,42 +79,20 @@ class SshTest < Test::Unit::TestCase
81
79
  @ssh.connect
82
80
  end
83
81
 
84
- context "on leopard" do
85
- setup do
86
- Vagrant::Util::Platform.stubs(:leopard?).returns(true)
87
- end
88
-
89
- teardown do
90
- Vagrant::Util::Platform.stubs(:leopard?).returns(false)
91
- end
92
-
93
- should "fork, exec, and wait" do
94
- pid = mock("pid")
95
- @ssh.expects(:fork).once.returns(pid)
96
- Process.expects(:wait).with(pid)
97
-
98
- @ssh.connect
99
- end
100
- end
101
-
102
82
  context "checking windows" do
103
- teardown do
104
- Mario::Platform.forced = Mario::Platform::Linux
105
- end
106
-
107
83
  should "error and exit if the platform is windows" do
108
- Mario::Platform.forced = Mario::Platform::Windows7
84
+ Vagrant::Util::Platform.stubs(:windows?).returns(true)
109
85
  assert_raises(Vagrant::Errors::SSHUnavailableWindows) { @ssh.connect }
110
86
  end
111
87
 
112
88
  should "not error and exit if the platform is anything other that windows" do
113
- Mario::Platform.forced = Mario::Platform::Linux
89
+ Vagrant::Util::Platform.stubs(:windows?).returns(false)
114
90
  assert_nothing_raised { @ssh.connect }
115
91
  end
116
92
  end
117
93
 
118
94
  def ssh_exec_expect(port, key_path, uname, host)
119
- Kernel.expects(:exec).with() do |arg|
95
+ @ssh.expects(:safe_exec).with() do |arg|
120
96
  assert arg =~ /^ssh/, "ssh command expected"
121
97
  assert arg =~ /-p #{port}/, "-p #{port} expected"
122
98
  assert arg =~ /-i #{key_path}/, "-i #{key_path} expected"
@@ -171,7 +147,7 @@ class SshTest < Test::Unit::TestCase
171
147
 
172
148
  should "yield an SSH session object" do
173
149
  raw = mock("raw")
174
- Net::SSH.expects(:start).yields(raw)
150
+ Net::SSH.expects(:start).returns(raw)
175
151
  @ssh.execute do |ssh|
176
152
  assert ssh.is_a?(Vagrant::SSH::Session)
177
153
  assert_equal raw, ssh.session
@@ -227,13 +203,6 @@ class SshTest < Test::Unit::TestCase
227
203
  }
228
204
  end
229
205
 
230
- should "return false if the connection is dropped" do
231
- Net::SSH.expects(:start).raises(Net::SSH::Disconnect)
232
- assert_nothing_raised {
233
- assert !@ssh.up?
234
- }
235
- end
236
-
237
206
  should "specifity the timeout as an option to execute" do
238
207
  @ssh.expects(:execute).yields(true).with() do |opts|
239
208
  assert_equal @env.config.ssh.timeout, opts[:timeout]
@@ -276,15 +245,11 @@ class SshTest < Test::Unit::TestCase
276
245
  @stat.stubs(:owned?).returns(true)
277
246
  File.stubs(:stat).returns(@stat)
278
247
 
279
- Mario::Platform.forced = Mario::Platform::Linux
280
- end
281
-
282
- teardown do
283
- Mario::Platform.forced = Mario::Platform::Linux
248
+ Vagrant::Util::Platform.stubs(:windows?).returns(false)
284
249
  end
285
250
 
286
251
  should "do nothing if on windows" do
287
- Mario::Platform.forced = Mario::Platform::Windows7
252
+ Vagrant::Util::Platform.stubs(:windows?).returns(true)
288
253
  File.expects(:stat).never
289
254
  @ssh.check_key_permissions(@key_path)
290
255
  end
@@ -31,15 +31,17 @@ class LinuxSystemTest < Test::Unit::TestCase
31
31
  setup do
32
32
  @name = "foo"
33
33
  @guestpath = "/bar"
34
+ @owner = "owner"
35
+ @group = "group"
34
36
  end
35
37
 
36
38
  should "create the dir, mount the folder, then set permissions" do
37
39
  mount_seq = sequence("mount_seq")
38
40
  @ssh.expects(:exec!).with("sudo mkdir -p #{@guestpath}").in_sequence(mount_seq)
39
- @instance.expects(:mount_folder).with(@ssh, @name, @guestpath).in_sequence(mount_seq)
40
- @ssh.expects(:exec!).with("sudo chown #{@vm.env.config.ssh.username} #{@guestpath}").in_sequence(mount_seq)
41
+ @instance.expects(:mount_folder).with(@ssh, @name, @guestpath, @owner, @group).in_sequence(mount_seq)
42
+ @ssh.expects(:exec!).with("sudo chown `id -u #{@owner}`:`id -g #{@group}` #{@guestpath}").in_sequence(mount_seq)
41
43
 
42
- @instance.mount_shared_folder(@ssh, @name, @guestpath)
44
+ @instance.mount_shared_folder(@ssh, @name, @guestpath, @owner, @group)
43
45
  end
44
46
  end
45
47
 
@@ -50,6 +52,8 @@ class LinuxSystemTest < Test::Unit::TestCase
50
52
  setup do
51
53
  @name = "foo"
52
54
  @guestpath = "bar"
55
+ @owner = "owner"
56
+ @group = "group"
53
57
  @sleeptime = 0
54
58
  @limit = 10
55
59
 
@@ -57,11 +61,11 @@ class LinuxSystemTest < Test::Unit::TestCase
57
61
  end
58
62
 
59
63
  def mount_folder
60
- @instance.mount_folder(@ssh, @name, @guestpath, @sleeptime)
64
+ @instance.mount_folder(@ssh, @name, @guestpath, @owner, @group, @sleeptime)
61
65
  end
62
66
 
63
67
  should "execute the proper mount command" do
64
- @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{@vm.env.config.ssh.username}`,gid=`id -g #{@vm.env.config.ssh.username}` #{@name} #{@guestpath}").returns(@success_return)
68
+ @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{@owner}`,gid=`id -g #{@group}` #{@name} #{@guestpath}").returns(@success_return)
65
69
  mount_folder
66
70
  end
67
71
 
@@ -96,19 +100,5 @@ class LinuxSystemTest < Test::Unit::TestCase
96
100
  mount_folder
97
101
  }
98
102
  end
99
-
100
- should "add uid AND gid to mount" do
101
- uid = "foo"
102
- gid = "bar"
103
- env = vagrant_env(vagrantfile(<<-vf))
104
- config.vm.shared_folder_uid = "#{uid}"
105
- config.vm.shared_folder_gid = "#{gid}"
106
- vf
107
-
108
- @vm.stubs(:env).returns(env)
109
-
110
- @ssh.expects(:exec!).with("sudo mount -t vboxsf -o uid=`id -u #{uid}`,gid=`id -g #{gid}` #{@name} #{@guestpath}").returns(@success_return)
111
- mount_folder
112
- end
113
103
  end
114
104
  end
@@ -0,0 +1,29 @@
1
+ require "test_helper"
2
+
3
+ class CounterUtilTest < Test::Unit::TestCase
4
+ setup do
5
+ @klass = Class.new do
6
+ extend Vagrant::Util::Counter
7
+ end
8
+ end
9
+
10
+ context "basic counter" do
11
+ should "get and update the counter" do
12
+ assert_equal 1, @klass.get_and_update_counter
13
+ assert_equal 2, @klass.get_and_update_counter
14
+ end
15
+ end
16
+
17
+ context "multiple classes with a counter" do
18
+ setup do
19
+ @klass2 = Class.new do
20
+ extend Vagrant::Util::Counter
21
+ end
22
+ end
23
+
24
+ should "not affect other classes" do
25
+ assert_equal 1, @klass.get_and_update_counter
26
+ assert_equal 1, @klass2.get_and_update_counter
27
+ end
28
+ end
29
+ end
@@ -6,12 +6,12 @@ class PlatformTest < Test::Unit::TestCase
6
6
  # This constant is not defined on non-windows platforms, so define it here
7
7
  File::BINARY = 4096 unless defined?(File::BINARY)
8
8
 
9
- Mario::Platform.expects(:windows?).returns(true)
9
+ Vagrant::Util::Platform.stubs(:windows?).returns(true)
10
10
  assert_equal Vagrant::Util::Platform.tar_file_options, File::CREAT|File::EXCL|File::WRONLY|File::BINARY
11
11
  end
12
12
 
13
13
  should "not include binary bit on other platforms" do
14
- Mario::Platform.expects(:windows?).returns(false)
14
+ Vagrant::Util::Platform.stubs(:windows?).returns(false)
15
15
  assert_equal Vagrant::Util::Platform.tar_file_options, File::CREAT|File::EXCL|File::WRONLY
16
16
  end
17
17
  end
data/vagrant.gemspec CHANGED
@@ -17,12 +17,11 @@ Gem::Specification.new do |s|
17
17
  s.add_dependency "archive-tar-minitar", "= 0.5.2"
18
18
  s.add_dependency "erubis", "~> 2.7.0"
19
19
  s.add_dependency "json", "~> 1.5.1"
20
- s.add_dependency "mario", "~> 0.0.6"
21
20
  s.add_dependency "net-ssh", "~> 2.1.4"
22
21
  s.add_dependency "net-scp", "~> 1.0.4"
23
22
  s.add_dependency "i18n", "~> 0.5.0"
24
23
  s.add_dependency "thor", "~> 0.14.6"
25
- s.add_dependency "virtualbox", "~> 0.8.3"
24
+ s.add_dependency "virtualbox", "~> 0.9.0"
26
25
 
27
26
  s.add_development_dependency "rake"
28
27
  s.add_development_dependency "contest", ">= 0.1.2"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrantup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hashimoto
@@ -53,20 +53,6 @@ dependencies:
53
53
  - - ~>
54
54
  - !ruby/object:Gem::Version
55
55
  version: 1.5.1
56
- - !ruby/object:Gem::Dependency
57
- name: mario
58
- requirement: !ruby/object:Gem::Requirement
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- version: 0.0.6
63
- type: :runtime
64
- prerelease: false
65
- version_requirements: !ruby/object:Gem::Requirement
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 0.0.6
70
56
  - !ruby/object:Gem::Dependency
71
57
  name: net-ssh
72
58
  requirement: !ruby/object:Gem::Requirement
@@ -129,14 +115,14 @@ dependencies:
129
115
  requirements:
130
116
  - - ~>
131
117
  - !ruby/object:Gem::Version
132
- version: 0.8.3
118
+ version: 0.9.0
133
119
  type: :runtime
134
120
  prerelease: false
135
121
  version_requirements: !ruby/object:Gem::Requirement
136
122
  requirements:
137
123
  - - ~>
138
124
  - !ruby/object:Gem::Version
139
- version: 0.8.3
125
+ version: 0.9.0
140
126
  - !ruby/object:Gem::Dependency
141
127
  name: rake
142
128
  requirement: !ruby/object:Gem::Requirement
@@ -254,12 +240,14 @@ files:
254
240
  - lib/vagrant/action/vm/host_name.rb
255
241
  - lib/vagrant/action/vm/import.rb
256
242
  - lib/vagrant/action/vm/match_mac_address.rb
243
+ - lib/vagrant/action/vm/modify.rb
257
244
  - lib/vagrant/action/vm/network.rb
258
245
  - lib/vagrant/action/vm/nfs.rb
259
246
  - lib/vagrant/action/vm/nfs_helpers.rb
260
247
  - lib/vagrant/action/vm/package.rb
261
248
  - lib/vagrant/action/vm/package_vagrantfile.rb
262
249
  - lib/vagrant/action/vm/provision.rb
250
+ - lib/vagrant/action/vm/provisioner_cleanup.rb
263
251
  - lib/vagrant/action/vm/resume.rb
264
252
  - lib/vagrant/action/vm/share_folders.rb
265
253
  - lib/vagrant/action/vm/suspend.rb
@@ -314,7 +302,7 @@ files:
314
302
  - lib/vagrant/provisioners.rb
315
303
  - lib/vagrant/provisioners/base.rb
316
304
  - lib/vagrant/provisioners/chef.rb
317
- - lib/vagrant/provisioners/chef_server.rb
305
+ - lib/vagrant/provisioners/chef_client.rb
318
306
  - lib/vagrant/provisioners/chef_solo.rb
319
307
  - lib/vagrant/provisioners/puppet.rb
320
308
  - lib/vagrant/provisioners/puppet_server.rb
@@ -331,16 +319,17 @@ files:
331
319
  - lib/vagrant/systems/linux/error.rb
332
320
  - lib/vagrant/systems/redhat.rb
333
321
  - lib/vagrant/systems/solaris.rb
322
+ - lib/vagrant/systems/suse.rb
334
323
  - lib/vagrant/systems/ubuntu.rb
335
324
  - lib/vagrant/test_helpers.rb
336
325
  - lib/vagrant/ui.rb
337
326
  - lib/vagrant/util.rb
338
327
  - lib/vagrant/util/busy.rb
328
+ - lib/vagrant/util/counter.rb
339
329
  - lib/vagrant/util/hash_with_indifferent_access.rb
340
- - lib/vagrant/util/plain_logger.rb
341
330
  - lib/vagrant/util/platform.rb
342
- - lib/vagrant/util/resource_logger.rb
343
331
  - lib/vagrant/util/retryable.rb
332
+ - lib/vagrant/util/safe_exec.rb
344
333
  - lib/vagrant/util/stacked_proc_runner.rb
345
334
  - lib/vagrant/util/template_renderer.rb
346
335
  - lib/vagrant/version.rb
@@ -387,12 +376,14 @@ files:
387
376
  - test/vagrant/action/vm/host_name_test.rb
388
377
  - test/vagrant/action/vm/import_test.rb
389
378
  - test/vagrant/action/vm/match_mac_address_test.rb
379
+ - test/vagrant/action/vm/modify_test.rb
390
380
  - test/vagrant/action/vm/network_test.rb
391
381
  - test/vagrant/action/vm/nfs_helpers_test.rb
392
382
  - test/vagrant/action/vm/nfs_test.rb
393
383
  - test/vagrant/action/vm/package_test.rb
394
384
  - test/vagrant/action/vm/package_vagrantfile_test.rb
395
385
  - test/vagrant/action/vm/provision_test.rb
386
+ - test/vagrant/action/vm/provisioner_cleanup_test.rb
396
387
  - test/vagrant/action/vm/resume_test.rb
397
388
  - test/vagrant/action/vm/share_folders_test.rb
398
389
  - test/vagrant/action/vm/suspend_test.rb
@@ -423,7 +414,7 @@ files:
423
414
  - test/vagrant/hosts/linux_test.rb
424
415
  - test/vagrant/plugin_test.rb
425
416
  - test/vagrant/provisioners/base_test.rb
426
- - test/vagrant/provisioners/chef_server_test.rb
417
+ - test/vagrant/provisioners/chef_client_test.rb
427
418
  - test/vagrant/provisioners/chef_solo_test.rb
428
419
  - test/vagrant/provisioners/chef_test.rb
429
420
  - test/vagrant/provisioners/puppet_server_test.rb
@@ -435,10 +426,9 @@ files:
435
426
  - test/vagrant/systems/linux_test.rb
436
427
  - test/vagrant/ui_test.rb
437
428
  - test/vagrant/util/busy_test.rb
429
+ - test/vagrant/util/counter_test.rb
438
430
  - test/vagrant/util/hash_with_indifferent_access_test.rb
439
- - test/vagrant/util/plain_logger_test.rb
440
431
  - test/vagrant/util/platform_test.rb
441
- - test/vagrant/util/resource_logger_test.rb
442
432
  - test/vagrant/util/retryable_test.rb
443
433
  - test/vagrant/util/stacked_proc_runner_test.rb
444
434
  - test/vagrant/util/template_renderer_test.rb
@@ -1,25 +0,0 @@
1
- require 'logger'
2
-
3
- module Vagrant
4
- module Util
5
- # Subclass of the standard library logger which has no format on
6
- # its own. The message sent to the logger is outputted as-is.
7
- class PlainLogger < ::Logger
8
- # This is the method which is called for all debug, info, error,
9
- # etc. methods by the logger. This is overriden to verify that
10
- # the output is always flushed.
11
- #
12
- # Logger by default syncs all log devices but this just verifies
13
- # it is truly flushed.
14
- def add(*args)
15
- super
16
- @logdev.dev.flush if @logdev
17
- end
18
-
19
- def format_message(level, time, progname, msg)
20
- # We do no formatting, its up to the user
21
- "#{msg}\n"
22
- end
23
- end
24
- end
25
- end
@@ -1,63 +0,0 @@
1
- require 'thread'
2
-
3
- module Vagrant
4
- module Util
5
- # Represents a logger for a specific resource within Vagrant. Each
6
- # logger should be initialized and set to represent a single
7
- # resource. Each logged message will then appear in the following
8
- # format:
9
- #
10
- # [resource] message
11
- #
12
- # This class is thread safe. The backing class which actually does
13
- # all the logging IO is protected.
14
- class ResourceLogger
15
- @@singleton_logger = nil
16
- @@writer_lock = Mutex.new
17
-
18
- # The resource which this logger represents.
19
- attr_reader :resource
20
-
21
- # The environment that this logger is part of
22
- attr_reader :env
23
-
24
- # The backing logger which actually handles the IO. This logger
25
- # should be a subclass of the standard library Logger, in general.
26
- # IMPORTANT: This logger must be thread-safe.
27
- attr_reader :logger
28
-
29
- class << self
30
- # Returns a singleton logger. If one has not yet be
31
- # instantiated, then the given environment will be used to
32
- # create a new logger.
33
- def singleton_logger(env=nil)
34
- return PlainLogger.new(nil) if !env.loaded?
35
-
36
- @@singleton_logger ||= begin
37
- file = env.log_path.join("#{Time.now.to_i}.log")
38
- PlainLogger.new(file)
39
- end
40
- end
41
-
42
- # Resets the singleton logger (only used for testing).
43
- def reset_singleton_logger!
44
- @@singleton_logger = nil
45
- end
46
- end
47
-
48
- def initialize(resource, env)
49
- @resource = resource
50
- @env = env
51
- @logger = self.class.singleton_logger(env)
52
- end
53
-
54
- [:debug, :info, :error, :fatal].each do |method|
55
- define_method(method) do |message|
56
- @@writer_lock.synchronize do
57
- logger.send(method, "[#{resource}] #{message}")
58
- end
59
- end
60
- end
61
- end
62
- end
63
- end
@@ -1,17 +0,0 @@
1
- require "test_helper"
2
-
3
- class PlainLoggerUtilTest < Test::Unit::TestCase
4
- setup do
5
- @klass = Vagrant::Util::PlainLogger
6
- @instance = @klass.new(nil)
7
- end
8
-
9
- should "inherit from the standard logger" do
10
- assert @instance.is_a?(::Logger)
11
- end
12
-
13
- should "just add a newline to the message" do
14
- msg = "foo bar baz"
15
- assert_equal "#{msg}\n", @instance.format_message("1", "2", "3", msg)
16
- end
17
- end