Skip to content

Instantly share code, notes, and snippets.

@ryantxr
Last active May 7, 2019 20:53
Show Gist options
  • Save ryantxr/fb2b2fa9fa63b34a1bd9 to your computer and use it in GitHub Desktop.
Save ryantxr/fb2b2fa9fa63b34a1bd9 to your computer and use it in GitHub Desktop.
Super simple logger for php. For those times when you are just throwing something together for a quick hack.
<?php
class Logger {
static function debug($msg) {
$file = dirname(__FILE__) . "/debug.log";
$output = strftime('%Y-%m-%d %T ') . ":" . $msg . "\n";
file_put_contents($file, $output, FILE_APPEND);
}
}
@ryantxr
Copy link
Author

ryantxr commented Mar 3, 2016

Here's how to use it:

require_once 'Logger.php';

Logger::debug("Here is my message");

In debug.log, you will see the output:
2016-11-23 22:12:45 Here is my message

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment