]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
added logging to the web page footer
authorcash <cash.costello@gmail.com>
Sat, 2 Jul 2011 16:07:27 +0000 (12:07 -0400)
committercash <cash.costello@gmail.com>
Sat, 2 Jul 2011 16:07:27 +0000 (12:07 -0400)
engine/classes/ElggPlugin.php
mod/developers/actions/developers/settings.php
mod/developers/classes/ElggLogCache.php [new file with mode: 0644]
mod/developers/languages/en.php
mod/developers/start.php
mod/developers/views/default/admin/developers/settings.php
mod/developers/views/default/developers/css.php
mod/developers/views/default/developers/log.php [new file with mode: 0644]

index 95a7362e24c5faa1827bbfa9a5770c6808194024..e46ac427398021bdbfe366d9bf566593fd85018f 100644 (file)
@@ -700,6 +700,11 @@ class ElggPlugin extends ElggObject {
 //                     return false;
 //             }
 
+               // include classes
+               if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) {
+                       $this->registerClasses();
+               }
+               
                // include start file
                if ($flags & ELGG_PLUGIN_INCLUDE_START) {
                        $this->includeFile('start.php');
@@ -715,11 +720,6 @@ class ElggPlugin extends ElggObject {
                        $this->registerLanguages();
                }
 
-               // include classes
-               if ($flags & ELGG_PLUGIN_REGISTER_CLASSES) {
-                       $this->registerClasses();
-               }
-
                return true;
        }
 
index d8be3486635b7cd76f190285eb75c5506d6a7c08..9fa96fa912c71234fbedea4b8c9197d897346aaf 100644 (file)
@@ -18,6 +18,7 @@ if (get_input('view_path_cache')) {
 }
 
 elgg_set_plugin_setting('display_errors', get_input('display_errors'), 'developers');
+elgg_set_plugin_setting('screen_log', get_input('screen_log'), 'developers');
 
 $debug = get_input('debug_level');
 if ($debug) {
@@ -26,4 +27,6 @@ if ($debug) {
        unset_config('debug', $site->getGUID());
 }
 
+system_message(elgg_echo('developers:settings:success'));
+
 forward(REFERER);
diff --git a/mod/developers/classes/ElggLogCache.php b/mod/developers/classes/ElggLogCache.php
new file mode 100644 (file)
index 0000000..19df598
--- /dev/null
@@ -0,0 +1,43 @@
+<?php
+/**
+ * Cache logging information for later display
+ *
+ */
+
+class ElggLogCache {
+       protected $cache;
+
+       public function __construct() {
+               $this->cache = array();
+       }
+
+       /**
+        * Insert into cache
+        * 
+        * @param mixed $data The log data to cache
+        */
+       public function insert($data) {
+               $this->cache[] = $data;
+       }
+
+       /**
+        * Insert into cache from plugin hook
+        * 
+        * @param string $hook
+        * @param string $type
+        * @param bool   $result 
+        * @param array  $params Must have the data at $params['msg']
+        */
+       public function insertDump($hook, $type, $result, $params) {
+               $this->insert($params['msg']);
+       }
+
+       /**
+        * Get the cache
+        *
+        * @return array
+        */
+       public function get() {
+               return $this->cache;
+       }
+}
index dc763765ce6b6b6bc95f0cccd46591da65c52f3e..053eed04fed07b2bf4f79b088a8dca42e48226f0 100644 (file)
@@ -21,6 +21,8 @@ $english = array(
        'developers:help:debug_level' => "This controls the amount of information logged. See elgg_log() for more information.",
        'developers:label:display_errors' => 'Display fatal PHP errors',
        'developers:help:display_errors' => "By default, Elgg's .htaccess file supresses the display of fatal errors.",
+       'developers:label:screen_log' => "Log to the screen",
+       'developers:help:screen_log' => "This displays elgg_log() and elgg_dump() output on the web page.",
 
        'developers:debug:off' => 'Off',
        'developers:debug:error' => 'Error',
@@ -41,6 +43,9 @@ $english = array(
        'theme_preview:modules' => 'Modules',
        'theme_preview:navigation' => 'Navigation',
        'theme_preview:typography' => 'Typography',
+
+       // status messages
+       'developers:settings:success' => 'Settings saved',
 );
 
 add_translation('en', $english);
index a53b7eec448df7c614cfdcc4cda92ac1330485fc..23b82d9db52dc7175fc29a82fb8641edc274e39a 100644 (file)
@@ -12,6 +12,7 @@ function developers_init() {
        elgg_register_event_handler('pagesetup', 'system', 'developers_setup_menu');
 
        elgg_extend_view('css/admin', 'developers/css');
+       elgg_extend_view('css/elgg', 'developers/css');
 
        elgg_register_page_handler('theme_preview', 'developers_theme_preview_controller');
 
@@ -32,6 +33,13 @@ function developers_process_settings() {
        } else {
                ini_set('display_errors', 0);
        }
+
+       if (elgg_get_plugin_setting('screen_log', 'developers') == 1) {
+               $cache = new ElggLogCache();
+               elgg_set_config('log_cache', $cache);
+               elgg_register_plugin_hook_handler('debug', 'log', array($cache, 'insertDump'));
+               elgg_extend_view('page/elements/foot', 'developers/log');
+       }
 }
 
 function developers_setup_menu() {
index 705ad00c6e0d312a477703fa4d27c5a3f298044c..3843c2c30bb2aae65ea96a7b02768d1479c471c9 100644 (file)
@@ -8,6 +8,7 @@ $sections = array(
        'view_path_cache' => 'checkbox',
        'display_errors' => 'checkbox',
        'debug_level' => 'pulldown',
+       'screen_log' => 'checkbox',
 );
 
 $data = array(
@@ -39,6 +40,12 @@ $data = array(
                        'NOTICE' => elgg_echo('developers:debug:notice'),
                ),
        ),
+
+       'screen_log' => array(
+               'type' => 'checkbox',
+               'value' => 1,
+               'checked' => elgg_get_plugin_setting('screen_log', 'developers') == 1,
+       ),
 );
 
 $form_vars = array('id' => 'developer-settings-form');
index 3aa226d0a96821a2b5dd9afa69f08aa0b6d3c420..4690945a9792281bca0df181fb54bbeb303ff487 100644 (file)
@@ -15,3 +15,9 @@
 .elgg-page .jstree-default.jstree-focused {
        background-color: transparent;
 }
+.developers-log {
+       background-color: #EBF5FF;
+       border: 1px solid #999;
+       color: #666;
+       padding: 20px;
+}
diff --git a/mod/developers/views/default/developers/log.php b/mod/developers/views/default/developers/log.php
new file mode 100644 (file)
index 0000000..eca2b4b
--- /dev/null
@@ -0,0 +1,16 @@
+<?php
+/**
+ * Logging information
+ */
+
+$cache = elgg_get_config('log_cache');
+$items = $cache->get();
+
+echo '<div class="developers-log">';
+foreach ($items as $item) {
+       echo '<pre>';
+       print_r($item);
+       echo '</pre>';
+}
+
+echo '</div>';
\ No newline at end of file