Skip to content

Instantly share code, notes, and snippets.

@categulario
Created August 13, 2014 13:24
Show Gist options
  • Save categulario/db7dcf454a3165d65602 to your computer and use it in GitHub Desktop.
Save categulario/db7dcf454a3165d65602 to your computer and use it in GitHub Desktop.
Simple helper for logging things to a file in php
<?php
if(!defined('STDOUT'))
{
define('STDOUT', fopen(base_path().'/application.log', 'a'));
}
/**
* provides an useful function for logging things to a file instead of sendind
* anything to the browser, for example var_dumps
*/
if(!function_exists('stdlog'))
{
function stdlog($var)
{
if(is_string($var))
{
fwrite(STDOUT, Carbon::now(Config::get('app.timezone'))->format('[c] ').$var.PHP_EOL);
}
else
{
$out = print_r($var, true);
fwrite(STDOUT, Carbon::now(Config::get('app.timezone'))->format('[c] '));
fwrite(STDOUT, $out.PHP_EOL);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment