Skip to content

Instantly share code, notes, and snippets.

@Nakilon
Created June 21, 2017 18:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nakilon/819369c5bf2e28a5ac24379f7e8a6db8 to your computer and use it in GitHub Desktop.
Save Nakilon/819369c5bf2e28a5ac24379f7e8a6db8 to your computer and use it in GitHub Desktop.
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