diff options
author | Guillaume Mazoyer <respawneral@gmail.com> | 2014-09-24 15:04:36 +0200 |
---|---|---|
committer | Guillaume Mazoyer <respawneral@gmail.com> | 2014-09-24 15:04:36 +0200 |
commit | a7d51630981d0bbf68bfa1fa059cd56d3fc634ce (patch) | |
tree | 8aa50945e1d82aa7e5202e516bd4300d3716eaf8 /includes | |
parent | 652b2723b3a2915acb65cd4af9ad775665ad8deb (diff) |
Log format can be configured.
The format for each log can be configured with the configuration
option defined by $config['logs']['format']. %D is for
the time, %R is for the requester IP address, %H is for the host on
which the command has been executed and %C is for the command.
Warning! The configuration option to choose the logs file has been
moved from $config['misc']['logs'] to $config['logs']['file'].
Diffstat (limited to 'includes')
-rw-r--r-- | includes/config.defaults.php | 11 | ||||
-rw-r--r-- | includes/utils.php | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/includes/config.defaults.php b/includes/config.defaults.php index eb411f7..4272bcc 100644 --- a/includes/config.defaults.php +++ b/includes/config.defaults.php @@ -26,10 +26,17 @@ $config = array( // Filters 'filters' => array(), + // Logs + 'logs' => array( + // Logs file when commands will be written + 'file' => '/var/log/looking-glass.log', + // Format for each logged command (%D is for the time, %R is for the + // requester IP address, %H is for the host and %C is for the command) + 'format' => '[%D] [client: %R] %H > %C' + ), + // Misc 'misc' => array( - // Logs file when commands will be written - 'logs' => '/var/log/looking-glass.log', // Allow private ASN 'allow_private_asn' => false, // Allow RFC1918 IPv4 and FD/FC IPv6 as parameters diff --git a/includes/utils.php b/includes/utils.php index 01b034c..ebbea2c 100644 --- a/includes/utils.php +++ b/includes/utils.php @@ -271,8 +271,8 @@ function fqdn_to_ip_address($fqdn) { function log_to_file($log) { global $config; - $log = '['.date("Y-m-d H:i:s").'] '.$log."\n"; - file_put_contents($config['misc']['logs'], $log, FILE_APPEND | LOCK_EX); + $log .= "\n"; + file_put_contents($config['logs']['file'], $log, FILE_APPEND | LOCK_EX); } // End of utils.php |