Example #1
0
 /**
  * Log a message to the logger
  *
  * @param string $message The message to log
  * @param string $category [optional] The message category (default "main")
  * @param integer $level [optional] The loglevel
  */
 public static function log($message, $category = 'main', $level = 1)
 {
     if (!self::$_logging_enabled) {
         return false;
     }
     if (self::$_loglevel > $level) {
         return false;
     }
     if (self::$_cli_log_to_screen_in_debug_mode && Context::isCLI() && Context::isDebugMode() && class_exists('\\thebuggenie\\core\\framework\\cli\\Command')) {
         \thebuggenie\core\framework\cli\Command::cli_echo(mb_strtoupper(self::getLevelName($level)), 'white', 'bold');
         \thebuggenie\core\framework\cli\Command::cli_echo(" [{$category}] ", 'green', 'bold');
         \thebuggenie\core\framework\cli\Command::cli_echo("{$message}\n");
     }
     if (self::$_logonajaxcalls || Context::getRequest()->isAjaxCall()) {
         if (self::$_logfile !== null) {
             file_put_contents(self::$_logfile, mb_strtoupper(self::getLevelName($level)) . " [{$category}] {$message}\n", FILE_APPEND);
         }
         $time_msg = Context::isDebugMode() ? ($load_time = Context::getLoadtime()) >= 1 ? round($load_time, 2) . ' seconds' : round($load_time * 1000, 3) . ' ms' : '';
         self::$_entries[] = array('category' => $category, 'time' => $time_msg, 'message' => $message, 'level' => $level);
         self::$_categorized_entries[$category][] = array('time' => $time_msg, 'message' => $message, 'level' => $level);
     }
 }
Example #2
0
 /**
  * Returns the HTML output from a component, but doesn't render it
  *
  * @param string $template the component name
  * @param array $params component parameters
  *
  * @return boolean
  */
 public static function returnComponentHTML($template, $params = array())
 {
     $current_content = ob_get_clean();
     Context::isCLI() ? ob_start() : ob_start('mb_output_handler');
     echo ActionComponent::includeComponent($template, $params);
     $component_content = ob_get_clean();
     Context::isCLI() ? ob_start() : ob_start('mb_output_handler');
     echo $current_content;
     return $component_content;
 }
Example #3
0
 public function isEnabled()
 {
     return Context::isCLI() ? false : $this->_enabled;
 }