示例#1
0
 /**
  * @param $string
  * @return mixed
  */
 public function write($string)
 {
     $time = microtime(true);
     if ($time - $this->lastWriteTime > $this->threshold) {
         $this->writer->write($string);
         $this->lastWriteTime = $time;
     }
 }
示例#2
0
/**
 * Display the log file contents for today
 *
 * @param string $q
 * @param array $matches
 * @param array $params
 */
function fn_logs($q, $matches, $params)
{
    $log_file = TITANIUM_ROOT . 'logs/' . date('Y-m-d') . '.txt';
    Logger::write("Reading log file: {$log_file}");
    if (file_exists($log_file)) {
        Output::write(file_get_contents($log_file), false, true);
    } else {
        Output::write("{$log_file} does not exist.", 'red', true);
    }
}
示例#3
0
文件: REPL.php 项目: rATRIJS/AIP
	protected function run_before_loop_exec() {
		$exec = \AIP\lib\Config::get(\AIP\lib\Config::OPTION_BEFORE_LOOP_EXEC);
		
		ob_start();
		foreach($exec as $line)
			$this->tick($line);
		$output = ob_get_clean();
		
		if(\AIP\lib\Config::get(\AIP\lib\Config::OPTION_VERBOSITY) > 0) {
			Output::write(\AIP\lib\srvr\evlr\Result::message("Start of 'before_loop_exec'"));
			Output::raw_write($output);
			Output::write(\AIP\lib\srvr\evlr\Result::message("End of 'before_loop_exec'"));
		}
	}
示例#4
0
文件: Debugger.php 项目: rATRIJS/AIP
	public static function debug($vars) {
		ob_get_clean();
		
		Evaluer::$path[] = 'debug';
		Evaluer::sandbox_vars($vars, false);
		
		$parser = new Parser;
		$interrupted = false;
		while(!$interrupted) {
			$line = Input::read(Evaluer::pathenize());
			$statement = $parser->parse($line);
			$result = Evaluer::execute($statement);
			Output::write($result);
			
			$interrupted = $statement->interrupted();
		}
		
		$vars = Evaluer::sandbox_vars();
		array_pop(Evaluer::$path);
		
		ob_start();
		
		return $vars;
	}
示例#5
0
/**
 * Display the help page
 *
 * @param string $q
 * @param array $matches
 * @param array $params
 */
function fn_help($q, $matches, $params)
{
    Logger::write("Running: " . __FUNCTION__);
    Output::write(Template::render('functions/help.tpl.php', $data), false, true);
}
示例#6
0
function print_ticker()
{
    if (RUN_MODE == 'INTERACTIVE') {
        Output::write(TICKER, 'bold');
    }
}
示例#7
0
#include_once('3rd-party/simplepie/idn/idna_convert.class.php');
# RSS init:
$rss = new Rss();
# Get the posts:
Debug::info("Getting the posts");
$posts = $rss->getPosts($Config->getFeeds());
# Write mode output openning:
Debug::info("Generating HTML output at " . OUTDIR . "/" . OUTFILE);
Debug::info("Generating RSS 2.0 output at " . OUTDIR . "/rss20.xml");
$fOutput = new Output();
#
# Output files generation:
#
# Header:
Debug::info("Headers");
$fOutput->write(File::ReadAndParse('html/header.html'));
$fOutput->writeRss(File::ReadAndParse('xml/rss20_head.xml'));
# Javascript:
Debug::info("HTML: Javascript functions");
$fOutput->write(File::Read('html/functions.js'));
# Body:
Debug::info("Bodies");
# The posts:
Debug::info("The posts");
$fOutput->write('<div id="posts">');
# Posts loop:
foreach ($posts as $post) {
    Debug::info("  Output (" . $post['author'] . ") " . $post['title']);
    $fOutput->write(File::ReadAndParse('html/post.html', $post));
    $fOutput->writeRss(File::ReadAndParse('xml/rss20_item.xml', $post));
}
/**
 * Display a list of the base class includes
 *
 * @param string $q
 * @param array $matches
 * @param array $params
 */
function fn_listincludes($q, $matches, $params)
{
    Logger::write("Running: " . __FUNCTION__);
    $data = array('includes' => Titanium::loaded_classes());
    Output::write(Template::render('functions/listincludes.tpl.php', $data), false, true);
}
示例#9
0
 /**
  * Outputs the help menu.
  *
  * @return PhpCli\Parser Returns $this, for object-chaining.
  */
 public function help()
 {
     echo PHP_EOL;
     $output = new Output();
     $output->write('Available Commands', ['color' => 'red', 'bold' => true, 'underline' => true]);
     echo PHP_EOL;
     $maxlen = 0;
     foreach ($this->supportedArgs as $key => $description) {
         $len = strlen($key);
         if ($len > $maxlen) {
             $maxlen = $len;
         }
     }
     foreach ($this->supportedArgs as $key => $description) {
         $len = strlen($key);
         $output->write(' ')->write($key, ['color' => 'yellow'])->write(str_repeat(' ', $maxlen - $len))->write(' - ')->write($description);
         echo PHP_EOL;
     }
     echo PHP_EOL;
 }
示例#10
0
文件: Io.php 项目: slince/console
 /**
  * 换行输入
  * 
  * @param string $message
  */
 function writeln($message = '')
 {
     $this->out->write($message, true);
 }
示例#11
0
/**
 * Display the tutorial page
 *
 * @param string $q
 * @param array $matches
 * @param array $params
 */
function fn_tutorial($q, $matches, $params)
{
    Logger::write("Running: " . __FUNCTION__);
    Output::write(Template::render('functions/tutorial.tpl.php'), false, true);
}
示例#12
0
 /**
  * Writes to an output and returns the output
  *
  * @param  var $value
  * @param  text.json.Output $output
  * @return text.json.Output The given output
  */
 public static function write($value, Output $output)
 {
     $output->write($value);
     return $output;
 }