]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Improve logging and add audit log
authorMarcin Haba <marcin.haba@bacula.pl>
Thu, 4 Aug 2022 14:38:15 +0000 (16:38 +0200)
committerMarcin Haba <marcin.haba@bacula.pl>
Thu, 4 Aug 2022 14:38:15 +0000 (16:38 +0200)
30 files changed:
gui/baculum/protected/API/Modules/BaculaConfig.php
gui/baculum/protected/API/Modules/BaculaSetting.php
gui/baculum/protected/API/Modules/BaculumAPIServer.php
gui/baculum/protected/API/Modules/BasicConfig.php
gui/baculum/protected/API/Modules/Bconsole.php
gui/baculum/protected/API/Modules/ChangerCommand.php
gui/baculum/protected/API/Modules/ComponentActions.php
gui/baculum/protected/API/Modules/Database.php
gui/baculum/protected/API/Modules/JSONTools.php
gui/baculum/protected/API/Modules/OAuth2/OAuth2Config.php
gui/baculum/protected/API/Pages/API/config.xml
gui/baculum/protected/API/Pages/OAuth2/config.xml
gui/baculum/protected/API/Pages/Panel/config.xml
gui/baculum/protected/Common/Modules/BFileLogRoute.php [new file with mode: 0644]
gui/baculum/protected/Common/Modules/ConfigIni.php
gui/baculum/protected/Common/Modules/Ldap.php
gui/baculum/protected/Common/Modules/Logging.php
gui/baculum/protected/Common/Modules/SessionRecord.php
gui/baculum/protected/Web/Modules/BaculumAPIClient.php
gui/baculum/protected/Web/Modules/DataDependencies.php
gui/baculum/protected/Web/Modules/HostConfig.php
gui/baculum/protected/Web/Modules/MessagesLog.php
gui/baculum/protected/Web/Modules/WebConfig.php
gui/baculum/protected/Web/Modules/WebRoleConfig.php
gui/baculum/protected/Web/Modules/WebUserConfig.php
gui/baculum/protected/Web/Modules/WebUserManager.php
gui/baculum/protected/Web/Pages/Security.php
gui/baculum/protected/Web/Pages/WebConfigWizard.php
gui/baculum/protected/Web/Pages/config.xml
gui/baculum/protected/Web/Portlets/BaculaConfigDirectives.php

index c815f2bb495ab778d3fa4ccf8664c52f1377c8c6..2a029f68688f123318318f86bc13ab565a8ea321 100644 (file)
@@ -106,11 +106,8 @@ class BaculaConfig extends ConfigFileModule {
                        $error = is_array($result['output']) ? implode('', $result['output']) : $result['output'];
                        $emsg = "ERROR [$component_type] $error";
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $ret;
index 5c8936d8990c16918d6fa05dedc67eaca2528903..dbf71cb4c60f95e65a4439a217055d7752f2d6a0 100644 (file)
@@ -384,11 +384,8 @@ class BaculaSetting extends APIModule {
                } else {
                        // It shouldn't happen.
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               "Attemp to update resource with different resource types.",
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               'Attemp to update resource with different resource types.'
                        );
                        $resource = $resource_orig;
                }
@@ -497,11 +494,8 @@ class BaculaSetting extends APIModule {
                } else {
                        $emsg = sprintf("Attemp to format a directive value with not supported value type '%s'.", gettype($value));
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $directive_value;
index ba8d5b5df0c44a71fc2620f907ab84765e18c33d..47e36a03ad1088b34c7b266ad03b6f8678bb3a29 100644 (file)
@@ -212,14 +212,7 @@ abstract class BaculumAPIServer extends TPage {
                                        break;
                                }
                        }
-               } catch(TException $e) {
-                       $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               "Method: {$_SERVER['REQUEST_METHOD']} $e",
-                               Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
-                       );
+               } catch (TException $e) {
                        if ($e instanceof BAPIException) {
                                $this->output = $e->getErrorMessage();
                                $this->error = $e->getErrorCode();
@@ -261,6 +254,8 @@ abstract class BaculumAPIServer extends TPage {
                } else {
                        $json = json_encode($output);
                }
+               $out = json_encode($output, JSON_PRETTY_PRINT);
+               $this->audit($out);
                return $json;
        }
 
@@ -285,6 +280,27 @@ abstract class BaculumAPIServer extends TPage {
                echo $this->getOutput();
        }
 
+       /**
+        * Write each request output to audit log.
+        * This method is dedicated for logging requests to API.
+        *
+        * @param string $output output string
+        */
+       private function audit($output) {
+               $username = isset($_SERVER['PHP_AUTH_USER']) ? $_SERVER['PHP_AUTH_USER'] : '-';
+               $msg = sprintf(
+                       "[%s] %s %s\n%s",
+                       $_SERVER['REQUEST_METHOD'],
+                       $username,
+                       $this->Request->getRequestUri(),
+                       $output
+               );
+               $this->getModule('logging')->log(
+                       Logging::CATEGORY_AUDIT,
+                       $msg
+               );
+       }
+
        /**
         * Shortcut method for getting application modules instances by
         * module name.
index d98ebc9a881e484dfac6345e5cfd858092cf964c..21a5041ec56eee62b35e42d0abf7928dd0589ee1 100644 (file)
@@ -122,11 +122,8 @@ class BasicConfig extends ConfigFileModule {
                                $is_valid = false;
                                $emsg = 'Invalid Basic user config. Missing ' . $this->required_options[$i] . ' option.';
                                $this->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_APPLICATION,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                                break;
                        }
index 1111c75f447de8dfa6cdfb2e707f4ad43f6b0f86..ca15b71b29155c6ff0de1d5e79b537cc89861014 100644 (file)
@@ -202,6 +202,7 @@ class Bconsole extends APIModule {
        private function execCommand($director, array $command, $ptype = null) {
                $cmd = '';
                $result = null;
+               $output = [];
                if(!is_null($director) && $this->isValidDirector($director) === false) {
                        throw new BConsoleException(
                                BconsoleError::MSG_ERROR_INVALID_DIRECTOR,
@@ -215,7 +216,7 @@ class Bconsole extends APIModule {
                        $cmd = $this->getCommand($pattern, $sudo, $dir, $bconsole_command);
                        exec($cmd['cmd'], $output, $exitcode);
                        if($exitcode != 0) {
-                               $emsg = ' Output=>' . implode("\n", $output) . ', Exitcode=>' . $exitcode;
+                               $emsg = ' Output=>' . implode(PHP_EOL, $output) . ', Exitcode=>' . $exitcode;
                                throw new BConsoleException(
                                        BconsoleError::MSG_ERROR_BCONSOLE_CONNECTION_PROBLEM . $emsg,
                                        BconsoleError::ERROR_BCONSOLE_CONNECTION_PROBLEM
@@ -232,11 +233,8 @@ class Bconsole extends APIModule {
                        }
                }
                $this->Application->getModule('logging')->log(
-                       $cmd['cmd'],
-                       $output,
                        Logging::CATEGORY_EXECUTE,
-                       __FILE__,
-                       __LINE__
+                       Logging::prepareOutput($cmd['cmd'], $output)
                );
 
                return $result;
index dae10bcd4ad4dea752273979b6dc22f773327cb8..5156a4ccbeee134ebc3c7ad2c6be8415fcb40821 100644 (file)
@@ -294,11 +294,8 @@ class ChangerCommand extends APIModule {
        public function execCommand($cmd, $ptype = null) {
                exec($cmd['cmd'], $output, $exitcode);
                $this->getModule('logging')->log(
-                       $cmd['cmd'],
-                       $output,
                        Logging::CATEGORY_EXECUTE,
-                       __FILE__,
-                       __LINE__
+                       Logging::prepareOutput($cmd['cmd'], $output)
                );
                if ($ptype === self::PTYPE_BG_CMD) {
                        $output = [
index 6dc008034302590336f04e5f7c36ad286b55790b..9ba0e43932096d97ce2d0cea9e52d1269ef1e91e 100644 (file)
@@ -113,7 +113,10 @@ class ComponentActions extends APIModule {
                $cmd_pattern = $this->getCmdPattern();
                $cmd = sprintf($cmd_pattern, $sudo, $bin);
                exec($cmd, $output, $exitcode);
-               $this->getModule('logging')->log($cmd, $output, Logging::CATEGORY_EXECUTE, __FILE__, __LINE__);
+               $this->getModule('logging')->log(
+                       Logging::CATEGORY_EXECUTE,
+                       Logging::prepareOutput($cmd, $output)
+               );
                $result = $this->prepareResult($output, $exitcode);
                return $result;
        }
index 329827bb300325f9e36711740a5f19ccdf4ab8e9..c13a7030f3618b53ffcc2732a91f972c2962f54b 100644 (file)
@@ -77,11 +77,8 @@ class Database extends APIModule {
                $logmsg = 'DBParams=%s, Connection=%s, TablesFormat=%s';
                $msg = sprintf($logmsg, print_r($db_params, true), var_export($is_connection, true), var_export($tables_format, true));
                $this->getModule('logging')->log(
-                       __FUNCTION__,
-                       $msg,
                        Logging::CATEGORY_APPLICATION,
-                       __FILE__,
-                       __LINE__
+                       $msg
                );
                return $is_connection;
        }
index 5accfefe03c77dd62791458e4b8d261bf4077a79..792b7dd1dfbdd235954aa901b7a63c0befbc4ab7 100644 (file)
@@ -49,7 +49,10 @@ class JSONTools extends APIModule
                $output_txt = implode('', $output);
                $out = json_decode($output_txt, true);
                if (!is_array($out)) {
-                       $this->getModule('logging')->log('Parse output', $output_txt, Logging::CATEGORY_EXTERNAL, __FILE__, __LINE__);
+                       $this->getModule('logging')->log(
+                               Logging::CATEGORY_EXTERNAL,
+                               "Parse output: $output_txt"
+                       );
                        $out = null;
                }
                return $out;
@@ -113,7 +116,10 @@ class JSONTools extends APIModule
                }
                $cmd = sprintf($cmd_pattern, $sudo, $bin, $cfg, $options);
                exec($cmd, $output, $exitcode);
-               $this->getModule('logging')->log($cmd, $output, Logging::CATEGORY_EXECUTE, __FILE__, __LINE__);
+               $this->getModule('logging')->log(
+                       Logging::CATEGORY_EXECUTE,
+                       Logging::prepareOutput($cmd, $output)
+               );
                if (!empty($config)) {
                        unlink($cfg);
                        if ($exitcode === 0) {
index 05f2ee6ea44fbd698ee7cd2ea103a7b211b63778..b127902fc82c806a44483d83a46a145fb8da2d39 100644 (file)
@@ -120,11 +120,8 @@ class OAuth2Config extends ConfigFileModule {
                                $is_valid = false;
                                $emsg = 'Invalid OAuth2 config. Missing ' . $this->required_options[$i] . ' option.';
                                $this->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_APPLICATION,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                                break;
                        }
index 4df7cbc0c794517128d977e8e3186a09dff2d343..683b2e0ce053db454947b1a8aa40e1cbca80c657 100644 (file)
@@ -40,7 +40,8 @@
                <module id="device_config" class="Baculum\API\Modules\DeviceConfig" />
                <!-- logging modules -->
                <module id="log" class="System\Util\TLogRouter">
-                       <route class="TFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\API\Logs" LogFile="baculum-api.log" MaxFileSize="1000" MaxLogFiles="5" />
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\API\Logs" LogFile="baculum-api-debug.log" MaxFileSize="10000" MaxLogFiles="5" />
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Audit" LogPath="Baculum\API\Logs" LogFile="baculum-api.log" MaxFileSize="10000" MaxLogFiles="5" />
                </module>
                <!-- component status modules -->
                <module id="status_dir" class="Baculum\API\Modules\StatusDirector" />
index d502acb1e75ef88872d0edde27fe593b40fa386a..591a0f9293c0a7efcea95e3e606a65418ed92676 100644 (file)
                <module id="oauth2_token" class="Baculum\API\Modules\OAuth2\TokenManager" />
                <!-- config modules -->
                <module id="api_config" class="Baculum\API\Modules\APIConfig" />
+               <!-- logging modules -->
+               <module id="log" class="System\Util\TLogRouter">
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\API\Logs" LogFile="baculum-api-debug.log" MaxFileSize="10000" MaxLogFiles="5" />
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Audit" LogPath="Baculum\API\Logs" LogFile="baculum-api.log" MaxFileSize="10000" MaxLogFiles="5" />
+               </module>
        </modules>
 </configuration>
index 66e21ad5e25ce516d8f7a2da1250f9f27da310e9..7e7a44dd36ba25e64b5669e40f8638629d6f5e24 100644 (file)
@@ -18,7 +18,8 @@
                </module>
                <!-- logging modules -->
                <module id="log" class="System\Util\TLogRouter">
-                       <route class="TFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\API\Logs" LogFile="baculum-api.log" MaxFileSize="1000" MaxLogFiles="5" />
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\API\Logs" LogFile="baculum-api-debug.log" MaxFileSize="10000" MaxLogFiles="5" />
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Audit" LogPath="Baculum\API\Logs" LogFile="baculum-api.log" MaxFileSize="10000" MaxLogFiles="5" />
                </module>
                <!-- auth modules -->
                <module id="basic_apiuser" class="Baculum\API\Modules\BasicAPIUserConfig" />
diff --git a/gui/baculum/protected/Common/Modules/BFileLogRoute.php b/gui/baculum/protected/Common/Modules/BFileLogRoute.php
new file mode 100644 (file)
index 0000000..0096867
--- /dev/null
@@ -0,0 +1,44 @@
+<?php
+/*
+ * Bacula(R) - The Network Backup Solution
+ * Baculum   - Bacula web interface
+ *
+ * Copyright (C) 2013-2022 Kern Sibbald
+ *
+ * The main author of Baculum is Marcin Haba.
+ * The original author of Bacula is Kern Sibbald, with contributions
+ * from many others, a complete list can be found in the file AUTHORS.
+ *
+ * You may use this file and others of this release according to the
+ * license defined in the LICENSE file, which includes the Affero General
+ * Public License, v3.0 ("AGPLv3") and some additional permissions and
+ * terms pursuant to its AGPLv3 Section 7.
+ *
+ * This notice must be preserved when any source code is
+ * conveyed and/or propagated.
+ *
+ * Bacula(R) is a registered trademark of Kern Sibbald.
+ */
+
+namespace Baculum\Common\Modules;
+
+use Prado\Util\TFileLogRoute;
+
+/**
+ * File log route class.
+ *
+ * @author Marcin Haba <marcin.haba@bacula.pl>
+ * @category Module
+ * @package Baculum Common
+ */
+class BFileLogRoute extends TFileLogRoute {
+
+       protected function formatLogMessage($message, $level, $category, $time) {
+               $t = date('Y-m-d H:i:s');
+               $c = sprintf('[%s]', $category);
+               return join(
+                       ' ',
+                       [$t, $c, $message]
+               );
+       }
+}
index d0168c016ade09f07acc58eef28dd95787bcbc1d..7ca7713c8c1af1721972baadc946a0cd742d6cc0 100644 (file)
@@ -163,11 +163,8 @@ class ConfigIni extends CommonModule implements IConfigFormat {
                        }
 
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $valid;
index cd64eeb9846a5043e9d89410f26e577f5dfda71d..fac3592a613351b234f402c653bc865165f1a7fb 100644 (file)
@@ -252,11 +252,8 @@ class Ldap extends CommonModule {
                );
                $this->error = $emsg;
                $this->getModule('logging')->log(
-                       __FUNCTION__,
-                       $emsg,
                        Logging::CATEGORY_EXTERNAL,
-                       __FILE__,
-                       __LINE__
+                       $emsg
                );
        }
 
index cfaa6535dd4511653a2edc77d0834d321e681aa6..b90dcfae44385618da3d12229d8ba23ca42b0c7d 100644 (file)
 namespace Baculum\Common\Modules;
 
 use Prado\Prado;
+use Prado\Util\TLogger;
 
 /**
- * Logger class.
+ * Main logger class.
  *
  * @author Marcin Haba <marcin.haba@bacula.pl>
  * @category Module
@@ -33,51 +34,97 @@ use Prado\Prado;
  */
 class Logging extends CommonModule {
 
+       /*
+        * Stores debug enable state.
+        *
+        * @var bool
+        */
        public static $debug_enabled = false;
 
+       /**
+        * Log categories.
+        */
        const CATEGORY_EXECUTE = 'Execute';
        const CATEGORY_EXTERNAL = 'External';
        const CATEGORY_APPLICATION = 'Application';
        const CATEGORY_GENERAL = 'General';
        const CATEGORY_SECURITY = 'Security';
+       const CATEGORY_AUDIT = 'Audit';
 
-       private function getLogCategories() {
-               $categories = array(
-                       self::CATEGORY_EXECUTE,
-                       self::CATEGORY_EXTERNAL,
-                       self::CATEGORY_APPLICATION,
-                       self::CATEGORY_GENERAL,
-                       self::CATEGORY_SECURITY
-               );
-               return $categories;
-       }
-
-       public function log($cmd, $output, $category, $file, $line) {
-               if(self::$debug_enabled !== true) {
+       /**
+        * Main log method used to log message.
+        *
+        * @param string $category log category
+        */
+       public function log($category, $message) {
+               if (!$this->isEnabled($category)) {
                        return;
                }
-               $current_mode = $this->Application->getMode();
+               $this->prepareMessage($category, $message);
+               Prado::log($message, TLogger::INFO, $category);
+       }
 
-               // switch application to debug mode
-               $this->Application->setMode('Debug');
+       /**
+        * Check if log is enabled.
+        *
+        * @param string $category log category
+        * @return bool true if log is enabled, otherwise false
+        */
+       private function isEnabled($category) {
+               $is_enabled = false;
+               if (self::$debug_enabled === true || $category === self::CATEGORY_AUDIT) {
+                       // NOTE: Audit log is written always, it is not possible to disable it
+                       $is_enabled = true;
+               }
+               return $is_enabled;
+       }
 
-               if(!in_array($category, $this->getLogCategories())) {
-                       $category = self::CATEGORY_SECURITY;
+       /**
+        * Prepare log to send to log manager.
+        *
+        * @param string $category log category
+        * @param array|string|object &$message log message reference
+        */
+       private function prepareMessage($category, &$message) {
+               if (is_object($message) || is_array($message)) {
+                       // make a message as string if needed
+                       $message = print_r($message, true);
                }
+               if (self::$debug_enabled === true && $category !== self::CATEGORY_AUDIT) {
+                       // If debug enabled, add file and line to log message
+                       $f = '';
+                       $trace = debug_backtrace();
+                       if (isset($trace[1]['file']) && isset($trace[1]['line'])) {
+                               $f = sprintf(
+                                       '%s:%s:',
+                                       basename($trace[1]['file']),
+                                       $trace[1]['line']
+                               );
+                       }
+                       $message = $f . $message;
+               }
+               $message .= PHP_EOL . PHP_EOL;
+       }
 
-               $log = sprintf(
-                       'Command=%s, Output=%s, File=%s, Line=%d',
+       /**
+        * Helper method for preparing logs that come from executing programs or scripts.
+        * This log consists of command and output.
+        * Useful for bconsole, b*json... and others.
+        *
+        * @param string $cmd command
+        * @param array|object|string $output command output
+        * @return string formatted command log
+        */
+       public static function prepareOutput($cmd, $output) {
+               if (is_array($output)) {
+                       $output = implode(PHP_EOL, $output);
+               } elseif(is_object($output)) {
+                       $output = print_r($output, true);
+               }
+               return sprintf(
+                       "\n\n===> Command:\n\n%s\n\n===> Output:\n\n%s",
                        $cmd,
-                       print_r($output, true),
-                       $file,
-                       intval($line)
+                       $output
                );
-
-               Prado::trace($log, $category);
-
-               // switch back application to original mode
-               $this->Application->setMode($current_mode);
        }
 }
-
-?>
index 58faaa7a4b19d1901f0267b15846334385c044ba..7329ac6ac52af6e21cdabdf77b36d18caa4de6d8 100644 (file)
@@ -68,11 +68,8 @@ class SessionRecord extends CommonModule implements ISessionItem {
                        } else {
                                $emsg = 'Unable to exclusive lock ' . $sessfile;
                                $this->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_APPLICATION,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                        }
                        fclose($fp);
@@ -94,11 +91,8 @@ class SessionRecord extends CommonModule implements ISessionItem {
                                } else {
                                        $emsg = 'Unable to shared lock ' . $sessfile;
                                        $this->getModule('logging')->log(
-                                               __FUNCTION__,
-                                               $emsg,
                                                Logging::CATEGORY_APPLICATION,
-                                               __FILE__,
-                                               __LINE__
+                                               $emsg
                                        );
                                }
                                fclose($fp);
index 885e0619d923852bf13a06ada9893c71f61f0f05..61c19cf877f4532715536a6b473eb2e5f648373f 100644 (file)
@@ -173,11 +173,8 @@ class BaculumAPIClient extends WebModule {
                        $this->addSpecialParams($uri);
 
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               PHP_EOL . PHP_EOL . 'EXECUTE URI ==> ' . $uri . ' <==' . PHP_EOL . PHP_EOL,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               'REQUEST URI => ' . $uri
                        );
                }
                return $uri;
@@ -433,11 +430,8 @@ class BaculumAPIClient extends WebModule {
        private function preParseOutput($result, $error, $errno, $show_error = true) {
                // first write log with that what comes
                $this->Application->getModule('logging')->log(
-                       __FUNCTION__,
-                       $result,
                        Logging::CATEGORY_APPLICATION,
-                       __FILE__,
-                       __LINE__
+                       $result
                );
 
                // decode JSON to object
@@ -462,11 +456,8 @@ class BaculumAPIClient extends WebModule {
                }
 
                $this->Application->getModule('logging')->log(
-                       __FUNCTION__,
-                       $resource,
                        Logging::CATEGORY_APPLICATION,
-                       __FILE__,
-                       __LINE__
+                       $resource
                );
 
                return $resource;
index be4df0f42baee66ea98b05daad00b0c3ac80d244..307f71159e349316898f4ba808dd38990a501b20 100644 (file)
@@ -61,7 +61,10 @@ class DataDependencies extends WebModule {
                        $data_deps = json_decode($deps_file);
                } else {
                        $emsg = "Data dependencies file '$deps_file' does not exist or is not readable.";
-                       $this->Application->getModule('logging')->log(__FUNCTION__, $emsg, Logging::CATEGORY_APPLICATION, __FILE__, __LINE__);
+                       $this->Application->getModule('logging')->log(
+                               Logging::CATEGORY_APPLICATION,
+                               $emsg
+                       );
                }
                return $data_deps;
        }
index 48630a57ca8cc901e6eecb01039e68e5be58ed0a..0a2e5f93479cb722c7551d2e119d595e834dd911 100644 (file)
@@ -175,11 +175,8 @@ class HostConfig extends ConfigFileModule {
                                $emsg = "ERROR [$path] Internal error";
                        }
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $valid;
index 312f74b1e173a6ddb3f90ed7b29ce4d9f69f3949..a99eafe5dd4000b1a8652f01b059b8357cccdf6f 100644 (file)
@@ -79,11 +79,8 @@ class MessagesLog extends WebModule {
                } else {
                        $emsg = 'Could not get the exclusive lock: ' . $f;
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                fclose($fp);
@@ -103,11 +100,8 @@ class MessagesLog extends WebModule {
                } else {
                        $emsg = 'Could not get the exclusive lock: ' . $f;
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                fclose($fp);
@@ -129,11 +123,8 @@ class MessagesLog extends WebModule {
                } else {
                        $emsg = 'Could not get the exclusive lock: ' . $f;
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                fclose($fp);
@@ -159,11 +150,8 @@ class MessagesLog extends WebModule {
                } else {
                        $emsg = 'Could not get the shared lock: ' . $f;
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                fclose($fp);
index b84c044b280d595a0a230c75c442712a859c33f3..ddc79116f08d20308fcc9d2cae7e8e5057a77316 100644 (file)
@@ -230,11 +230,8 @@ class WebConfig extends ConfigFileModule {
                if ($ret !== true) {
                        $emsg = 'Error while saving auth basic config.';
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $ret;
index 247bdf1648fdecc4770b416b2be5e8e11558b587..8231d76c57ab7c9eba2b2a7549b080177f7bb483 100644 (file)
@@ -176,11 +176,8 @@ class WebRoleConfig extends ConfigFileModule {
                        for ($i = 0; $i < $required_len; $i++) {
                                $emsg = "ERROR [$path] Required {$invalid['required'][$i]['type']} '{$invalid['required'][$i]['value']}' not found for role '{$invalid['required'][$i]['role']}.";
                                $this->Application->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_APPLICATION,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                        }
                }
index d2825ee9d2a644fa2febe03aacd7ecf8187da773..8f9b3b142b007a2c7ee81432f9074e2791cd5727 100644 (file)
@@ -245,11 +245,8 @@ class WebUserConfig extends ConfigFileModule {
                        $ret = false;
                        $emsg = 'Error while importing basic users.';
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $ret;
index 82d11cfc0d967a2f559c0f7d40043ad6f58159c7..237714874a3f0e50fdadc10284caccd223b82032 100644 (file)
@@ -242,11 +242,8 @@ class WebUserManager extends WebModule implements IUserManager {
                        } else {
                                $emsg = 'Basic auth is enabled, but PHP_AUTH_USER is not set or is empty.';
                                $this->Application->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_SECURITY,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                        }
                }
index 09713d9e7f7af2e30c342129742d71dadf26e4e0..3982981c35d07e4256589ecb115efb3b4f5edfac 100644 (file)
@@ -836,11 +836,8 @@ class Security extends BaculumWebPage {
                        if (!key_exists($params['user_attr'], $users[$i])) {
                                $emsg = "User attribute '{$params['user_attr']}' doesn't exist in LDAP response.";
                                $this->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_EXTERNAL,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                                continue;
                        }
@@ -848,11 +845,8 @@ class Security extends BaculumWebPage {
                        if ($params['user_attr'] !== Ldap::DN_ATTR && $users[$i][$params['user_attr']]['count'] != 1) {
                                $emsg = "Invalid user attribute count for '{$params['user_attr']}'. Is {$users[$i][$params['user_attr']]['count']}, should be 1.";
                                $this->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_EXTERNAL,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                                continue;
 
index e4a9177eb842e8455f05736204d00524e71757f4..aaf36647eee89db95adf139e19ce6bd241ce8550 100644 (file)
@@ -148,11 +148,8 @@ class WebConfigWizard extends BaculumWebPage
                        } else {
                                $emsg = 'Error while saving basic user config.';
                                $this->getModule('logging')->log(
-                                       __FUNCTION__,
-                                       $emsg,
                                        Logging::CATEGORY_APPLICATION,
-                                       __FILE__,
-                                       __LINE__
+                                       $emsg
                                );
                        }
 
@@ -168,11 +165,8 @@ class WebConfigWizard extends BaculumWebPage
                                if (!$ret) {
                                        $emsg = 'Error while saving user config.';
                                        $this->getModule('logging')->log(
-                                               __FUNCTION__,
-                                               $emsg,
                                                Logging::CATEGORY_APPLICATION,
-                                               __FILE__,
-                                               __LINE__
+                                               $emsg
                                        );
                                }
 
@@ -185,11 +179,8 @@ class WebConfigWizard extends BaculumWebPage
                } else {
                        $emsg = 'Error while saving auth host config.';
                        $this->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
        }
index 804728fcbef8596a4388e46c32d192cad05e05ad..21502937e420d73326939aaf51dfb373d54fbecb 100644 (file)
@@ -17,7 +17,7 @@
                        <translation type="gettext" source="Baculum\Web\Lang" marker="@@" autosave="false" cache="false" DefaultCulture="en" />
                </module>
                <module id="log" class="System\Util\TLogRouter">
-                       <route class="TFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\Web\Logs" LogFile="baculum-web.log" MaxFileSize="1000" MaxLogFiles="5" />
+                       <route class="Baculum\Common\Modules\BFileLogRoute"  Categories="Execute, External, Application, General, Security" LogPath="Baculum\Web\Logs" LogFile="baculum-web-debug.log" MaxFileSize="10000" MaxLogFiles="5" />
                </module>
                <module id="log_parser" class="Baculum\Web\Modules\LogParser" />
                <!-- auth modules -->
index 2f1c1b542c2444d11ae46d2996ad3a163f141074..62a68f115f799295d14aa16b2f1ef8c59f92ebc2 100644 (file)
@@ -609,11 +609,8 @@ class BaculaConfigDirectives extends DirectiveListTemplate {
                        $success = false;
                        $emsg = 'Error while renaming resource: ' . $result->output;
                        $this->Application->getModule('logging')->log(
-                               __FUNCTION__,
-                               $emsg,
                                Logging::CATEGORY_APPLICATION,
-                               __FILE__,
-                               __LINE__
+                               $emsg
                        );
                }
                return $success;