Created
September 29, 2022 17:27
-
-
Save djuber/6fc224ed2bb3523ee103c1a02e85dc74 to your computer and use it in GitHub Desktop.
add logging to rake invocation by prepending Task#execute
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rake/task' | |
module Logging | |
module Rake | |
module Task | |
def execute(args) | |
message = { | |
rake_task: { | |
name: self.name, | |
arguments: args.to_a | |
} | |
} | |
# inject call time logging here | |
puts message | |
# now run the called task | |
super | |
end | |
end | |
end | |
end | |
module Rake | |
class Task | |
prepend(Logging::Rake::Task) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment