PluginProbe
MBE eShip / trunk
MBE eShip vtrunk
2.8.1 trunk 1.0.0 1.1.0 1.1.3 1.2.1 1.2.2 1.3.0 1.4.0 1.4.1 1.5.0 1.5.1 1.5.2 1.6.0 1.7.0 1.7.1 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.1.0 2.1.1 2.1.2 2.2.1 All 37 releases
mail-boxes-etc / lib / Helper / Logger.php

Logger.php in MBE eShip trunk, at lib/Helper/Logger.php

55 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class Mbe_Shipping_Helper_Logger
4 {
5 public static $log = true;
6
7 private $helper;
8 private $pluginVersionMessage;
9
10 public function __construct()
11 {
12 $this->helper = new Mbe_Shipping_Helper_Data();
13 $this->pluginVersionMessage = MBE_ESHIP_PLUGIN_NAME.' version ' . MBE_ESHIP_PLUGIN_VERSION . ' :';
14 }
15
16 public function log($message, $force = false)
17 {
18 if ($this->helper->debug() || $force) {
19
20
21 $logDirPath = $this->helper->getMbeLogDir(); // returns the path checking if it exists and if it's missing it creates it
22
23 // if the directory already exists but the permissions are wrongs, changes it
24 if(file_exists($logDirPath) && substr(sprintf('%o', fileperms($logDirPath)), -4)<>0755 ) {
25 chmod( $logDirPath, 0755 );
26 }
27
28 // if(substr(sprintf('%o', fileperms(MBE_ESHIP_PLUGIN_LOG_DIR)), -4)<>0755 ) {
29 // chmod( MBE_ESHIP_PLUGIN_LOG_DIR, 0755 );
30 // }
31 //
32 // if (!file_exists(MBE_ESHIP_PLUGIN_LOG_DIR ) ) {
33 // mkdir(MBE_ESHIP_PLUGIN_LOG_DIR , 0755, true);
34 // }
35
36 if(!file_exists(trailingslashit($logDirPath) . '.htaccess')) {
37 $this->helper->createHtaccessDenyAll($logDirPath);
38 }
39
40 $row = date_format(new DateTime(), 'Y-m-d\TH:i:s\Z');
41 $row .= " - ";
42 $row .= $this->pluginVersionMessage . $message . "\n\r";
43 file_put_contents($this->helper->getLogPluginPath(), $row, FILE_APPEND);
44 }
45 }
46
47
48 public function logVar($var, $message = null, $force = false)
49 {
50 if ($message) {
51 $this->log($message, $force);
52 }
53 $this->log(print_r($var, true),$force);
54 }
55 }