Created
August 13, 2014 13:24
-
-
Save categulario/db7dcf454a3165d65602 to your computer and use it in GitHub Desktop.
Simple helper for logging things to a file in php
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
<?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