×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: Matt Parry
Added: Aug 20, 2016 11:36 AM
Modified: May 30, 2017 12:19 PM
Views: 16
Tags: no tags
  1. function logger( $log ) {      
  2.         $tDate=date("d-M-Y G:i:s");
  3.         $site=$_SERVER["HTTP_HOST"];
  4.         $myfile = fopen($_SERVER['DOCUMENT_ROOT']."\\logs\\custlog.txt", "a+") or die("Unable to open file!");
  5.         fwrite($myfile, "\n".$site." | ". $log." - ".$tDate);
  6.         fclose($myfile);       
  7. }
  8.  
  9. function dumper($params, $chCopy)
  10. {
  11.     $data = array();
  12.     $data['CALL'] = $params['api_call'];
  13.     $data['cURL'] = $chCopy;
  14.     $data['response'] = $params;
  15.  
  16.     $f = fopen('../logs/' . $data["CALL"] . '/' . date("Y-m-d") . '_api.log', 'a+b');
  17.     $trace = debug_backtrace();
  18.  
  19.     if (DEBUG) {
  20.         $data['trace'] = $trace;
  21.         $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
  22.     } else {
  23.         $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);  // COMMENT OUT IN PROD AND TURN DEBUG OFF - COMPACTS LOGS
  24.         // $json=json_encode($data, JSON_UNESCAPED_SLASHES);
  25.     }
  26.  
  27.     fwrite($f, $json . "\n");
  28.     fclose($f);
  29. }