Last active
March 5, 2019 11:06
-
-
Save mehdichaouch/d994f425b21258cbc3ef871babc8be64 to your computer and use it in GitHub Desktop.
PimpMyLog: Magento dynamic and static configuration (Need to be improved)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/*! pimpmylog - 1.7.14 - 025d83c29c6cf8dbb697aa966c9e9f8713ec92f1*/ | |
/* | |
* pimpmylog | |
* http://pimpmylog.com | |
* | |
* Copyright (c) 2017 Potsky, contributors | |
* Licensed under the GPLv3 license. | |
*/ | |
?> | |
<?php if (realpath(__FILE__) === realpath($_SERVER["SCRIPT_FILENAME"])) { | |
header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); | |
die(); | |
} ?> | |
<?php | |
// Inspired from: https://web.archive.org/web/20170318145649/https://ktree.com/blog/pimpmylogs-magento.html | |
######################################################################################################################## | |
#### Conf: only one "true" | |
$dynamicConf = true; | |
$staticConf = false; | |
######################################################################################################################## | |
#### Static conf | |
if ($dynamicConf && !$staticConf): | |
// Dynamic Folders for Windows | |
$directories = array( | |
'Apache Error Logs' => array('match' => 'apache_error', 'directory' => 'C:\\wamp64\\logs\\', 'format' => 'general'), | |
'Apache Access Logs' => array('match' => 'access', 'directory' => 'C:\\wamp64\\logs\\', 'format' => 'access'), | |
// 'Syslog Error Logs' => array('match' => 'syslog', 'directory' => '/var/log/', 'format' => 'general'), | |
'Mysql Error Logs' => array('match' => 'mariadb', 'directory' => 'C:\\wamp64\\logs\\', 'format' => 'general'), | |
'Magento Logs' => array('match' => '.log', 'directory' => 'C:\\Magento\\var\\log\\', 'format' => 'magento'), | |
'Magento Reports' => array('match' => '', 'directory' => 'C:\\Magento\\var\\report\\', 'format' => 'general') | |
); | |
$generalFormat = array( | |
'regex' => '|^(.*)$|U', | |
'export_title' => 'Log', | |
'match' => | |
array( | |
'Log' => 1, | |
), | |
'types' => | |
array( | |
'Log' => 'txt', | |
), | |
'exclude' => | |
array( | |
'Log' => | |
array( | |
0 => '/PHP Stack trace:/', | |
1 => '/PHP *[0-9]*\. /', | |
), | |
), | |
); | |
$accessLogFormat = array( | |
'regex' => ' |^(.*) (.*) (.*) \[(.*)\] "(.*) (.*) (.*)" ([0-9]*) (.*) "(.*)" "(.*)"( [0-9]*/([0-9]*))*$|U', | |
'export_title' => 'URL', | |
'match' => | |
array( | |
'Date' => 4, | |
'IP' => 1, | |
'CMD' => 5, | |
'URL' => 6, | |
'Code' => 8, | |
'Size' => 9, | |
'Referer' => 10, | |
'UA' => 11, | |
'User' => 3, | |
'μs' => 13, | |
), | |
'types' => | |
array( | |
'Date' => 'date:H:i:s', | |
'IP' => 'ip:geo', | |
'URL' => 'txt', | |
'Code' => 'badge:http', | |
'Size' => 'numeral:0b', | |
'Referer' => 'link', | |
'UA' => 'ua:{os.name} {os.version} | {browser.name} {browser.version}/100', | |
'μs' => 'numeral:0,0', | |
), | |
'exclude' => | |
array( | |
'URL' => | |
array( | |
0 => '/favicon.ico/', | |
1 => '/\.pml\.php.*$/', | |
), | |
'CMD' => | |
array( | |
0 => '/OPTIONS/', | |
), | |
), | |
); | |
$magentoLogFormat = array( | |
'type' => 'PHP', | |
'regex' => '@^(.*)\-(.*)\-(.*)T(.*)\:(.*)\:(.*)\+(.*)\:(.*)\ (.*)\ \((.*)\)\:\ (((.*) in (.*) on line (.*))|(.*))$@U', | |
'match' => | |
array( | |
'Date' => | |
array( | |
0 => 3, | |
1 => '-', | |
2 => 2, | |
3 => '-', | |
4 => 1, | |
5 => ' ', | |
6 => 4, | |
7 => ':', | |
8 => 5, | |
9 => ':', | |
10 => 6, | |
), | |
'Severity' => 9, | |
'Error' => | |
array( | |
0 => 12, | |
1 => 13, | |
), | |
'File' => 14, | |
'Line' => 15, | |
), | |
'types' => | |
array( | |
'Date' => 'date:d-m-Y H:i:s', | |
'Severity' => 'badge:severity', | |
'File' => 'pre:/-69', | |
'Line' => 'numeral', | |
'Error' => 'pre', | |
), | |
'exclude' => | |
array( | |
'Log' => | |
array( | |
0 => '\/PHP Stack trace:\/', | |
1 => '\/PHP *[0-9]*\. \/', | |
), | |
), | |
); | |
$files = array(); | |
foreach ($directories as $magentoDirKey => $directory) | |
if (file_exists($directory['directory']) && $handle = opendir($directory['directory'])) { | |
switch ($directory['format']) { | |
case 'access' : | |
$format = $accessLogFormat; | |
break; | |
case 'magento' : | |
$format = $magentoLogFormat; | |
break; | |
default: | |
$format = $generalFormat; | |
} | |
$sortFiles = array(); | |
while (false !== ($entry = readdir($handle))) { | |
if ($entry != "." && $entry != ".." && (!$directory['match'] || ((strpos($entry, $directory['match']) !== false) && (strpos($entry, '.gz') === false)))) { | |
$sortFiles[$entry] = array('filename' => $entry, 'filetime' => filemtime($directory['directory'] . $entry)); | |
} | |
} | |
closedir($handle); | |
usort($sortFiles, function ($a, $b) { | |
return $a['filetime'] - $b['filetime']; | |
}); | |
$sortFiles = array_reverse($sortFiles); | |
foreach ($sortFiles as $sortKey => $sortFile) { | |
$files[$sortFile['filename']] = array( | |
'display' => $sortFile['filename'], | |
'path' => $directory['directory'] . $sortFile['filename'], | |
'refresh' => 5, | |
'max' => 10, | |
'notify' => true, | |
'multiline' => '', | |
"tags" => array(array('main_tag' => $magentoDirKey, 'sub_tag' => date("d-m-Y", $sortFile['filetime']))), | |
'format' => $format, | |
); | |
} | |
} | |
$pimpConfig = array( | |
'globals' => | |
array( | |
'_remove_me_to_set_AUTH_LOG_FILE_COUNT' => 100, | |
'_remove_me_to_set_AUTO_UPGRADE' => false, | |
'_remove_me_to_set_CHECK_UPGRADE' => true, | |
'_remove_me_to_set_EXPORT' => true, | |
'_remove_me_to_set_FILE_SELECTOR' => 'bs', | |
'_remove_me_to_set_FOOTER' => '© <a href="http://www.potsky.com" target="doc">Potsky</a> 2007-' . YEAR . ' - <a href="http://pimpmylog.com" target="doc">Pimp my Log</a>', | |
'_remove_me_to_set_FORGOTTEN_YOUR_PASSWORD_URL' => 'http://support.pimpmylog.com/kb/misc/forgotten-your-password', | |
'_remove_me_to_set_GEOIP_URL' => 'http://www.geoiptool.com/en/?IP=%p', | |
'_remove_me_to_set_GOOGLE_ANALYTICS' => 'UA-XXXXX-X', | |
'_remove_me_to_set_HELP_URL' => 'http://pimpmylog.com', | |
'_remove_me_to_set_LOCALE' => 'gb_GB', | |
'_remove_me_to_set_LOGS_MAX' => 50, | |
'_remove_me_to_set_LOGS_REFRESH' => 0, | |
'_remove_me_to_set_MAX_SEARCH_LOG_TIME' => 5, | |
'_remove_me_to_set_NAV_TITLE' => '', | |
'_remove_me_to_set_NOTIFICATION' => true, | |
'_remove_me_to_set_NOTIFICATION_TITLE' => 'New logs [%f]', | |
'_remove_me_to_set_PIMPMYLOG_ISSUE_LINK' => 'https://github.com/potsky/PimpMyLog/issues/', | |
'_remove_me_to_set_PIMPMYLOG_VERSION_URL' => 'http://demo.pimpmylog.com/version.js', | |
'_remove_me_to_set_PULL_TO_REFRESH' => true, | |
'_remove_me_to_set_SORT_LOG_FILES' => 'default', | |
'_remove_me_to_set_TAG_DISPLAY_LOG_FILES_COUNT' => true, | |
'_remove_me_to_set_TAG_NOT_TAGGED_FILES_ON_TOP' => true, | |
'_remove_me_to_set_TAG_SORT_TAG' => 'default | display-asc | display-insensitive | display-desc | display-insensitive-desc', | |
'_remove_me_to_set_TITLE' => 'Pimp my Log', | |
'_remove_me_to_set_TITLE_FILE' => 'Pimp my Log [%f]', | |
'_remove_me_to_set_UPGRADE_MANUALLY_URL' => 'http://pimpmylog.com/getting-started/#update', | |
'_remove_me_to_set_USER_CONFIGURATION_DIR' => 'config.user.d', | |
'_remove_me_to_set_USER_TIME_ZONE' => 'Europe/Paris', | |
), | |
'badges' => | |
array( | |
'severity' => | |
array( | |
'debug' => 'success', | |
'info' => 'success', | |
'notice' => 'default', | |
'Notice' => 'info', | |
'warn' => 'warning', | |
'error' => 'danger', | |
'crit' => 'danger', | |
'alert' => 'danger', | |
'emerg' => 'danger', | |
'Fatal error' => 'danger', | |
'Parse error' => 'danger', | |
'Warning' => 'warning', | |
), | |
'http' => | |
array( | |
1 => 'info', | |
2 => 'success', | |
3 => 'default', | |
4 => 'warning', | |
5 => 'danger', | |
), | |
), | |
'files' => $files, | |
); | |
// header('Content-type:application/json;charset=utf-8'); | |
echo json_encode($pimpConfig); | |
// die; | |
endif; | |
?> | |
<?php | |
######################################################################################################################## | |
#### Static conf | |
if (!$dynamicConf && $staticConf): ?> | |
{ | |
"globals": { | |
"_remove_me_to_set_AUTH_LOG_FILE_COUNT" : 100, | |
"_remove_me_to_set_AUTO_UPGRADE" : false, | |
"_remove_me_to_set_CHECK_UPGRADE" : true, | |
"_remove_me_to_set_EXPORT" : true, | |
"_remove_me_to_set_FILE_SELECTOR" : "bs", | |
"_remove_me_to_set_FOOTER" : "© <a href=\"http:\/\/www.potsky.com\" target=\"doc\">Potsky<\/a> 2007-' . YEAR . ' - <a href=\"http:\/\/pimpmylog.com\" target=\"doc\">Pimp my Log<\/a>", | |
"_remove_me_to_set_FORGOTTEN_YOUR_PASSWORD_URL" : "http:\/\/support.pimpmylog.com\/kb\/misc\/forgotten-your-password", | |
"_remove_me_to_set_GEOIP_URL" : "http:\/\/www.geoiptool.com\/en\/?IP=%p", | |
"_remove_me_to_set_PORT_URL" : "http:\/\/www.adminsub.net\/tcp-udp-port-finder\/%p", | |
"_remove_me_to_set_GOOGLE_ANALYTICS" : "UA-XXXXX-X", | |
"_remove_me_to_set_HELP_URL" : "http:\/\/pimpmylog.com", | |
"_remove_me_to_set_LOCALE" : "gb_GB", | |
"_remove_me_to_set_LOGS_MAX" : 50, | |
"_remove_me_to_set_LOGS_REFRESH" : 0, | |
"_remove_me_to_set_MAX_SEARCH_LOG_TIME" : 5, | |
"_remove_me_to_set_NAV_TITLE" : "", | |
"_remove_me_to_set_NOTIFICATION" : true, | |
"_remove_me_to_set_NOTIFICATION_TITLE" : "New logs [%f]", | |
"_remove_me_to_set_PIMPMYLOG_ISSUE_LINK" : "https:\/\/github.com\/potsky\/PimpMyLog\/issues\/", | |
"_remove_me_to_set_PIMPMYLOG_VERSION_URL" : "http:\/\/demo.pimpmylog.com\/version.js", | |
"_remove_me_to_set_PULL_TO_REFRESH" : true, | |
"_remove_me_to_set_SORT_LOG_FILES" : "default", | |
"_remove_me_to_set_TAG_DISPLAY_LOG_FILES_COUNT" : true, | |
"_remove_me_to_set_TAG_NOT_TAGGED_FILES_ON_TOP" : true, | |
"_remove_me_to_set_TAG_SORT_TAG" : "default | display-asc | display-insensitive | display-desc | display-insensitive-desc", | |
"_remove_me_to_set_TITLE" : "Pimp my Log", | |
"_remove_me_to_set_TITLE_FILE" : "Pimp my Log [%f]", | |
"_remove_me_to_set_UPGRADE_MANUALLY_URL" : "http:\/\/pimpmylog.com\/getting-started\/#update", | |
"_remove_me_to_set_USER_CONFIGURATION_DIR" : "config.user.d", | |
"_remove_me_to_set_USER_TIME_ZONE" : "Europe\/Paris" | |
}, | |
"badges": { | |
"severity": { | |
"debug" : "success", | |
"info" : "success", | |
"notice" : "default", | |
"Notice" : "info", | |
"warn" : "warning", | |
"error" : "danger", | |
"crit" : "danger", | |
"alert" : "danger", | |
"emerg" : "danger", | |
"Notice" : "info", | |
"fatal error" : "danger", | |
"parse error" : "danger", | |
"Warning" : "warning" | |
}, | |
"http": { | |
"1" : "info", | |
"2" : "success", | |
"3" : "default", | |
"4" : "warning", | |
"5" : "danger" | |
} | |
}, | |
"files": { | |
"apache - error log": { | |
"display" : "Error log", | |
"path" : "C:\\wamp64\\logs\\apache_error.log", | |
"refresh" : 5, | |
"max" : 10, | |
"notify" : true, | |
"tags": [ | |
"Apache" | |
], | |
"format" : { | |
"type" : "HTTPD 2.4", | |
"regex" : "|^\\[(.*) (.*) (.*) (.*):(.*):(.*)\\.(.*) (.*)\\] \\[(.*):(.*)\\] \\[pid (.*)\\] .*\\[client (.*):(.*)\\] (.*)(, referer: (.*))*$|U", | |
"export_title" : "Log", | |
"match" : { | |
"Date" : { | |
"M" : 2, | |
"d" : 3, | |
"H" : 4, | |
"i" : 5, | |
"s" : 6, | |
"Y" : 8 | |
}, | |
"IP" : 12, | |
"Log" : 14, | |
"Severity" : 10, | |
"Referer" : 16 | |
}, | |
"types": { | |
"Date" : "date:H:i:s", | |
"IP" : "ip:http", | |
"Log" : "preformatted", | |
"Severity" : "badge:severity", | |
"Referer" : "link" | |
}, | |
"exclude": { | |
"Log": ["\/PHP Stack trace:\/", "\/PHP *[0-9]*\\. \/"] | |
} | |
} | |
}, | |
"apache - access log": { | |
"display" : "Access log", | |
"path" : "C:\\wamp64\\logs\\access.log", | |
"refresh" : 0, | |
"max" : 10, | |
"notify" : false, | |
"tags": [ | |
"Apache" | |
], | |
"format" : { | |
"type" : "NCSA", | |
"regex" : "|^((\\S*) )*(\\S*) (\\S*) (\\S*) \\[(.*)\\] \"(\\S*) (.*) (\\S*)\" ([0-9]*) (.*)( \"(.*)\" \"(.*)\"( [0-9]*/([0-9]*))*)*$|U", | |
"export_title" : "URL", | |
"match" : { | |
"Date" : 6, | |
"IP" : 3, | |
"CMD" : 7, | |
"URL" : 8, | |
"Code" : 10, | |
"Size" : 11, | |
"Referer" : 13, | |
"UA" : 14, | |
"User" : 5, | |
"\u03bcs" : 16 | |
}, | |
"types": { | |
"Date" : "date:H:i:s", | |
"IP" : "ip:geo", | |
"URL" : "txt", | |
"Code" : "badge:http", | |
"Size" : "numeral:0b", | |
"Referer" : "link", | |
"UA" : "ua:{os.name} {os.version} | {browser.name} {browser.version}\/100", | |
"\u03bcs" : "numeral:0,0" | |
}, | |
"exclude": { | |
"URL": ["\/favicon.ico\/", "\/\\.pml\\.php.*$\/"], | |
"CMD": ["\/OPTIONS\/"] | |
} | |
} | |
}, | |
"php - error log": { | |
"display" : "Error log", | |
"path" : "c:\/wamp64\/logs\\php_error.log", | |
"refresh" : 5, | |
"max" : 10, | |
"notify" : true, | |
"tags": [ | |
"PHP" | |
], | |
"format" : { | |
"type" : "PHP", | |
"regex" : "@^\\[(.*)-(.*)-(.*) (.*):(.*):(.*)( (.*))*\\] ((PHP (.*): (.*) in (.*) on line (.*))|(.*))$@U", | |
"export_title" : "Error", | |
"match" : { | |
"Date" : [ 2 , " " , 1 , " " , 4 , ":" , 5 , ":" , 6 , " " , 3 ], | |
"Severity" : 11, | |
"Error" : [ 12 , 15 ], | |
"File" : 13, | |
"Line" : 14 | |
}, | |
"types" : { | |
"Date" : "date:H:i:s", | |
"Severity" : "badge:severity", | |
"File" : "pre:\/-69", | |
"Line" : "numeral", | |
"Error" : "pre" | |
}, | |
"exclude": { | |
"Log": ["\\/PHP Stack trace:\\/", "\\/PHP *[0-9]*\\. \\/"] | |
} | |
} | |
}, | |
"Magento - system.log": { | |
"display": "system.log", | |
"path": "C:\\Magento\\var\\log\\system.log", | |
"refresh": 5, | |
"max": 10, | |
"export": true, | |
"notify": true, | |
"tags": [ | |
"Magento" | |
], | |
"multiline": "", | |
"format": { | |
"type": "PHP", | |
"regex": "@^(.*)\\-(.*)\\-(.*)T(.*):(.*):(.*)(\\+(.*)\\:) ((.*)\\:) (((.*) in (.*) on line (.*))|(.*))$@U", | |
"match": { | |
"Date": [ | |
3, | |
"-", | |
2, | |
"-", | |
1, | |
" ", | |
4, | |
":", | |
5, | |
":", | |
6 | |
], | |
"Severity": 10, | |
"Error": [ | |
12, | |
13 | |
], | |
"File": 14, | |
"Line": 15 | |
}, | |
"types": { | |
"Date": "date:H:i:s", | |
"Severity": "badge:severity", | |
"File": "pre:/-69", | |
"Line": "numeral", | |
"Error": "pre" | |
}, | |
"exclude": { | |
"Log": [ | |
"\\/PHP Stack trace:\\/", | |
"\\/PHP *[0-9]*\\. \\/" | |
] | |
} | |
} | |
}, | |
"Magento - background_ERR.log": { | |
"display": "background_ERR.log", | |
"path": "C:\\Magento\\var\\log\\background_ERR.log", | |
"refresh": 5, | |
"max": 10, | |
"export": true, | |
"notify": true, | |
"tags": [ | |
"Magento" | |
], | |
"multiline": "", | |
"format": { | |
"type": "PHP", | |
"regex": "@^(.*)\\-(.*)\\-(.*)T(.*):(.*):(.*)(\\+(.*)\\:) ((.*)\\:) (((.*) in (.*) on line (.*))|(.*))$@U", | |
"match": { | |
"Date": [ | |
3, | |
"-", | |
2, | |
"-", | |
1, | |
" ", | |
4, | |
":", | |
5, | |
":", | |
6 | |
], | |
"Severity": 10, | |
"Error": [ | |
12, | |
13 | |
], | |
"File": 14, | |
"Line": 15 | |
}, | |
"types": { | |
"Date": "date:H:i:s", | |
"Severity": "badge:severity", | |
"File": "pre:/-69", | |
"Line": "numeral", | |
"Error": "pre" | |
}, | |
"exclude": { | |
"Log": [ | |
"\\/PHP Stack trace:\\/", | |
"\\/PHP *[0-9]*\\. \\/" | |
] | |
} | |
} | |
}, | |
"Magento - ASP00392_17.log": { | |
"display": "ASP00392_17.log", | |
"path": "C:\\Magento\\var\\log\\ASP00392_17.log", | |
"refresh": 5, | |
"max": 10, | |
"export": true, | |
"notify": true, | |
"tags": [ | |
"Magento" | |
], | |
"multiline": "", | |
"format": { | |
"type": "PHP", | |
"regex": "@^(.*)\\-(.*)\\-(.*)T(.*):(.*):(.*)(\\+(.*)\\:) ((.*)\\:) (((.*) in (.*) on line (.*))|(.*))$@U", | |
"match": { | |
"Date": [ | |
3, | |
"-", | |
2, | |
"-", | |
1, | |
" ", | |
4, | |
":", | |
5, | |
":", | |
6 | |
], | |
"Severity": 10, | |
"Error": [ | |
12, | |
13 | |
], | |
"File": 14, | |
"Line": 15 | |
}, | |
"types": { | |
"Date": "date:H:i:s", | |
"Severity": "badge:severity", | |
"File": "pre:/-69", | |
"Line": "numeral", | |
"Error": "pre" | |
}, | |
"exclude": { | |
"Log": [ | |
"\\/PHP Stack trace:\\/", | |
"\\/PHP *[0-9]*\\. \\/" | |
] | |
} | |
} | |
}, | |
"Magento - exception.log": { | |
"display": "exception.log", | |
"path": "C:\\Magento\\var\\log\\exception.log", | |
"refresh": 5, | |
"max": 10, | |
"export": true, | |
"notify": true, | |
"tags": [ | |
"Magento" | |
], | |
"multiline": "", | |
"format": { | |
"type": "PHP", | |
"regex": "@^(.*)\\-(.*)\\-(.*)T(.*):(.*):(.*)(\\+(.*)\\:) ((.*)\\:) (((.*) in (.*) on line (.*))|(.*))$@U", | |
"match": { | |
"Date": [ | |
3, | |
"-", | |
2, | |
"-", | |
1, | |
" ", | |
4, | |
":", | |
5, | |
":", | |
6 | |
], | |
"Severity": 10, | |
"Error": [ | |
12, | |
13 | |
], | |
"File": 14, | |
"Line": 15 | |
}, | |
"types": { | |
"Date": "date:H:i:s", | |
"Severity": "badge:severity", | |
"File": "pre:/-69", | |
"Line": "numeral", | |
"Error": "pre" | |
}, | |
"exclude": { | |
"Log": [ | |
"\\/PHP Stack trace:\\/", | |
"\\/PHP *[0-9]*\\. \\/" | |
] | |
} | |
} | |
} | |
} | |
} | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment