File tree 7 files changed +41
-1
lines changed
7 files changed +41
-1
lines changed Original file line number Diff line number Diff line change @@ -6,3 +6,4 @@ vendor/bundle/*
6
6
.ruby-version
7
7
buildpacks /*
8
8
.anvil /
9
+ tmp /* .log
Original file line number Diff line number Diff line change 1
1
language : ruby
2
2
rvm :
3
- - 2.4.1
3
+ - 2.4.3
4
4
before_script : bundle exec rake hatchet:setup_travis
5
5
script : bundle exec parallel_rspec -n 11 spec/
6
6
env :
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ require "fileutils"
2
2
require "tmpdir"
3
3
require 'hatchet/tasks'
4
4
5
+ ENV [ "BUILDPACK_LOG_FILE" ] ||= "tmp/buildpack.log"
6
+
5
7
S3_BUCKET_NAME = "heroku-buildpack-ruby"
6
8
VENDOR_URL = "https://s3.amazonaws.com/#{ S3_BUCKET_NAME } "
7
9
Original file line number Diff line number Diff line change @@ -93,6 +93,7 @@ def compile
93
93
puts @deprecations . join ( "\n " )
94
94
end
95
95
end
96
+ mcount "success.ruby"
96
97
end
97
98
98
99
def write_release_yaml
Original file line number Diff line number Diff line change @@ -14,6 +14,18 @@ module LanguagePack
14
14
module ShellHelpers
15
15
@@user_env_hash = { }
16
16
17
+ def mcount ( key , value = 1 )
18
+ private_log ( "count" , key => value )
19
+ end
20
+
21
+ def mmeasure ( key , value )
22
+ private_log ( "measure" , key => value )
23
+ end
24
+
25
+ def munique ( key , value )
26
+ private_log ( "unique" , key => value )
27
+ end
28
+
17
29
def self . user_env_hash
18
30
@@user_env_hash
19
31
end
@@ -149,5 +161,14 @@ def deprecate(message)
149
161
def noshellescape ( string )
150
162
NoShellEscape . new ( string )
151
163
end
164
+
165
+ private
166
+ def private_log ( name , key_value_hash )
167
+ File . open ( ENV [ "BUILDPACK_LOG_FILE" ] , "a+" ) do |f |
168
+ key_value_hash . each do |key , value |
169
+ f . puts "#{ name } ##{ ENV [ "BPLOG_PREFIX" ] } #{ key } =#{ value } "
170
+ end
171
+ end
172
+ end
152
173
end
153
174
end
Original file line number Diff line number Diff line change @@ -14,6 +14,21 @@ class FakeShell
14
14
include LanguagePack ::ShellHelpers
15
15
end
16
16
17
+ describe "mcount" do
18
+ it "logs to a file" do
19
+ begin
20
+ original = ENV [ "BUILDPACK_LOG_FILE" ]
21
+ Tempfile . open ( "logfile.log" ) do |f |
22
+ ENV [ "BUILDPACK_LOG_FILE" ] = f . path
23
+ FakeShell . new . mcount "foo"
24
+ expect ( File . read ( f . path ) ) . to match ( "count#foo=1" )
25
+ end
26
+ ensure
27
+ ENV [ "BUILDPACK_LOG_FILE" ] = original
28
+ end
29
+ end
30
+ end
31
+
17
32
describe "#command_options_to_string" do
18
33
it "formats ugly keys correctly" do
19
34
env = { %Q{ un"matched } => "bad key" }
You can’t perform that action at this time.
0 commit comments