Skip to content

Instantly share code, notes, and snippets.

@bgadrian
Created March 16, 2015 17:33
Show Gist options
  • Save bgadrian/4798a9a09eee01206d55 to your computer and use it in GitHub Desktop.
Save bgadrian/4798a9a09eee01206d55 to your computer and use it in GitHub Desktop.
PHP Simplest way to log actions
<?php
//just TEXT log any action, and info about it, like a purchase, use for backup/internal storage
//I use this for all types of requests, when dealing with online payments
/* LOG */
file_put_contents('logs/'.date('Y.m').'.pay.log','['.$_SERVER['REMOTE_ADDR'].'] '.date('Y.m.d-H:i:s').': Order ID : '.$order_id.', Error : '.$error.', Sum'.$payed_sum.', Transaction : '.$transaction_id.PHP_EOL,FILE_APPEND);
//I recommend to keep the comma, for eventual csv reading
//automatically creates a single file per month, keeping the logs small
//keeps the IP and time stamp in a nice juman form
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment