BPMediaLog

The rtMedia for WordPress, BuddyPress and bbPress BPMediaLog class.

Defined (1)

The class is defined in the following location(s).

/app/helper/BPMediaLog.php  
  1. class BPMediaLog { 
  2. /** 
  3. * Formats and logs the error message 
  4. * @param any $msg The message to log 
  5. * @param string $context The context string, optional 
  6. * @return boolean True if successful 
  7. */ 
  8.  
  9. /** 
  10. * @param type $msg 
  11. * @param string $context 
  12. * @param string $log_file 
  13. * @return type 
  14. */ 
  15. public function __construct( $msg, $context = '', $log_file = '' ) { 
  16. $log_msg = $this->log_msg( $msg, $context = '' ); 
  17. if ( $log_file == '' ) { 
  18. $log_file = RTMEDIA_PATH . 'log/rtmedia.log'; 
  19. return $this->log( $log_msg, $log_file ); 
  20.  
  21. /** 
  22. * Formats the message 
  23. * @param any $msg The message to format 
  24. * @param string $context The context string, optional 
  25. * @return string The formatted log entry 
  26. */ 
  27.  
  28. /** 
  29. * @param type $msg 
  30. * @param type $context 
  31. * @return type 
  32. */ 
  33. function log_msg( $msg, $context = '' ) { 
  34. $logmsg = gmdate( "Y-m-d H:i:s " ) . " | "; 
  35. if ( $context ) { 
  36. $logmsg .= $context . " | "; 
  37. if ( ! is_string( $msg ) ) { 
  38. $msg = var_export( $msg, false ); 
  39. $logmsg .= $msg; 
  40. return $logmsg; 
  41.  
  42. /** 
  43. * Logs the entry to the log file 
  44. * @param string $logmsg The formatted log entry 
  45. * @param string $file The log file's path 
  46. * @return boolean Success 
  47. */ 
  48.  
  49. /** 
  50. * @param type $logmsg 
  51. * @param type $file 
  52. * @return boolean 
  53. */ 
  54. public function log( $logmsg, $file ) { 
  55. $fp = fopen( RTMEDIA_PATH . 'plugin.log', "a+" ); 
  56. if ( $fp ) { 
  57. fwrite( $fp, "\n" . $logmsg ); 
  58. fclose( $fp ); 
  59. return true; 
  60.