Skip to content

Commit 9c78a59

Browse files
committed
expose a logger to all handlers
1 parent 61db77d commit 9c78a59

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

lib/hooks/handlers/base.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ class Base
1616
def call(payload:, headers:, config:)
1717
raise NotImplementedError, "Handler must implement #call method"
1818
end
19+
20+
# Short logger accessor for all subclasses
21+
# @return [Hooks::Log] Logger instance
22+
#
23+
# Provides a convenient way for handlers to log messages without needing
24+
# to reference the full Hooks::Log namespace.
25+
#
26+
# @example Logging an error in an inherited class
27+
# log.error("oh no an error occured")
28+
def log
29+
Hooks::Log.instance
30+
end
1931
end
2032
end
2133
end

spec/acceptance/handlers/github_handler.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class GithubHandler < Hooks::Handlers::Base
99
# @param config [Hash] Endpoint configuration
1010
# @return [Hash] Response data
1111
def call(payload:, headers:, config:)
12+
log.info("🚀 Processing GitHub webhook 🚀")
1213
return {
1314
status: "success"
1415
}

0 commit comments

Comments
 (0)