method log documentation in bbn\X

Saves logs to a file.

Example

X::log('My text', 'FileName'); function($st, string $file = 'misc') { if (\defined('BBN_DATA_PATH') && is_dir(BBN_DATA_PATH.'logs')) { $log_file = BBN_DATA_PATH.'logs/'.$file.'.log'; $backtrace = array_filter( debug_backtrace(), function ($a) { return $a['function'] === 'log'; } ); $i = end($backtrace); $r = "[".date('d/m/Y H:i:s')."]\t".$i['file']." - line ".$i['line']. self::getDump($st).PHP_EOL; if (php_sapi_name() === 'cli') { global $argv; if (isset($argv[2]) && ($argv[2] === 'log')) { echo self::getDump($st).PHP_EOL; } } if (file_exists($log_file) && filesize($log_file) > BBN_X_MAX_LOG_FILE) { file_put_contents($log_file.'.old', file_get_contents($log_file), FILE_APPEND); file_put_contents($log_file, $r); } else{ file_put_contents($log_file, $r, FILE_APPEND); } } }

Saves logs to a file. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.