public function fmt($msg, $level = 'INFO') { $b = debug_backtrace(); foreach ($b as $c) { if (false === strpos($c['file'], 'LogFmt.php') && false === strpos($c['file'], 'TinyLog.php')) { break; } } if (false === is_string($msg)) { $msg = preg_replace("/\\s+/i", '', var_export($msg, true)); } $string = sprintf("%s:%s " . PHP_EOL . "%s:%s" . PHP_EOL . "%s" . PHP_EOL, $level, $msg, $c['file'], $c['line'], microtime(true)); $old_log = rpcache::get('log'); if (is_array($old_log) && is_array($old_log[$level])) { array_push($old_log[$level], $string); rpcache::set('log', $old_log); } return $string; }
<?php include dirname(__DIR__) . "/src/rpcache.php"; use netroby\rpcache\rpcache; $a = "sdadfadsafsd"; echo $a; rpcache::set("mykey", $a); var_dump(rpcache::has("mykey")); var_dump(rpcache::get("mykey"));
<?php include dirname(__DIR__) . '/vendor/autoload.php'; use netroby\tinylog\TinyLog as TinyLogA; use netroby\rpcache\rpcache; $log = new TinyLogA(); $get = array(2, 4, 6); $log->info('Runinng begin'); $log->info($get); $log->error("I am error Test"); var_dump(rpcache::get('log'));