Last active
March 25, 2024 08:18
-
-
Save sudogem/4f57e286fb38c94dbe26bfcdfbcea453 to your computer and use it in GitHub Desktop.
Create custom log file
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
# | |
# Create a file my_log.rb in app/models | |
# Copy & paste the code below in my_log.rb | |
class MyLog | |
class << self | |
def debug(msg) | |
File.open("log/logs.txt", "a+") { | |
|file| | |
file.write(msg) | |
file.write("\n") | |
} | |
end | |
end | |
end | |
# Example usage: | |
MyLog.debug("result data here") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment