Skip to content

Instantly share code, notes, and snippets.

@0x1eef

0x1eef/logger.rb Secret

Created May 3, 2023 10:18
Show Gist options
  • Save 0x1eef/b834293c83d7928acb36b23e13d0b774 to your computer and use it in GitHub Desktop.
Save 0x1eef/b834293c83d7928acb36b23e13d0b774 to your computer and use it in GitHub Desktop.
class MyClass
def initialize; end
def log(level, msg)
puts "#{level}: #{msg}"
end
[:debug, :info].each do |m|
define_method(m) do |msg|
log(__method__, msg)
end
end
# same code for warn, error, fatal, unknown
end
MyClass.new.debug "foo"
MyClass.new.info "bar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment