Skip to content

Instantly share code, notes, and snippets.

@djuber
Created September 29, 2022 17:27
Show Gist options
  • Save djuber/6fc224ed2bb3523ee103c1a02e85dc74 to your computer and use it in GitHub Desktop.
Save djuber/6fc224ed2bb3523ee103c1a02e85dc74 to your computer and use it in GitHub Desktop.
add logging to rake invocation by prepending Task#execute
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