Created
June 21, 2017 18:02
-
-
Save Nakilon/819369c5bf2e28a5ac24379f7e8a6db8 to your computer and use it in GitHub Desktop.
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
Google::Cloud::Logging::Logger.class_eval do | |
%i{ debug info warn error }.each do |level| | |
old = instance_method level | |
define_method level do |message, entry_labels = {}, &block| | |
logger_labels = @labels if @labels | |
begin | |
@labels = (@labels || {}).merge entry_labels | |
old.bind(self).(message, &block) | |
ensure | |
@labels = logger_labels | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment