function jsonlog_default_file in JSONlog 7
Establish default logging file path.
Directory default: PHP:ini error_log - unless that is 'syslog' (then checks the usual suspects /var/log/...) - plus /drupal-jsonlog.
Filename default: jsonlog site ID .log.json.
Return value
string Empty upon failure.
4 calls to jsonlog_default_file()
- jsonlog_form_system_logging_settings_alter in ./
jsonlog.module - Adds this module's setting fields to the system logging settings form.
- jsonlog_form_system_logging_settings_submit in ./
jsonlog.module - Custom submit handler for the system logging settings form.
- jsonlog_test_filing in ./
jsonlog.inc - Checks if log dir+file exists and is writable, and logs to watchdog.
- jsonlog_watchdog in ./
jsonlog.module - Logs any watchdog call - at or above a certain severity threshold - as JSON to a custom log file.
File
- ./
jsonlog.inc, line 43 - JSONlog module helper functions.
Code
function jsonlog_default_file() {
if ($file = getenv('drupal_jsonlog_file')) {
return $file;
}
// Default web server log dir for common *nix distributions.
$default_log_dirs = array(
'debian' => '/var/log/apache2',
'redhat' => '/var/log/httpd',
);
$dir = '';
if (!($server_log = ini_get('error_log')) || $server_log === 'syslog') {
// Try default web server log dirs for common *nix distributions.
foreach ($default_log_dirs as $val) {
if (file_exists($val)) {
$dir = $val;
break;
}
}
}
else {
$dir = str_replace('\\', '/', dirname($server_log));
}
if ($dir) {
if (!($site_id = variable_get('jsonlog_siteid'))) {
$site_id = jsonlog_default_site_id();
}
return $dir . '/drupal-jsonlog/' . $site_id . '.log.json';
}
return '';
}