/** * @param array $params * @return string */ public function cancel(array $params) { $status = $this->transaction->cancel(array_merge($params, $this->getMerchantCredentials())); if ($this->loggingIsEnabled()) { $this->log->info("Cancelled the transaction with ID: {$params['transactionId']}. Status: {$status}"); } return $status; }
/** * Main Runner */ public function run() { try { $console = new Console(); $render = null; $destinationProcessedCount = 0; $destinationProcessedSuccessCount = 0; $taxonomyFilePath = $console->inputDir . DS . BatchProcessor::app()->config->get('taxonomy_file'); $destinationsFilePath = $console->inputDir . DS . BatchProcessor::app()->config->get('destinations_file'); if (!file_exists($console->outputDir)) { $console->close("`{$console->outputDir}` output directory does not exists.", Console::ERROR_OUT); } if (!is_writable($console->outputDir)) { $console->close("Specified output directory is not writable.", Console::ERROR_OUT); } $this->logger = new Logger($console->outputDir . DS . 'log'); $console->write(date('F j, Y, H:i:s') . " :: Starting file processing..."); $this->logger->notice('----------------------'); $this->logger->info('Started file processing'); $render = new HtmlRender(BatchProcessor::app()->config->get('template_dir_path'), $console->outputDir); $destinationHandler = new DestinationHandler($destinationsFilePath); $taxonomyHandler = new TaxonomyHandler($taxonomyFilePath); while ($destination = $destinationHandler->fetch()) { if (!$taxonomyHandler->hasNode($destination)) { $this->logger->alert('Destination with atlas id ' . $destination->id . ' node details not found in taxonomy.'); } $fileName = self::makeFileName($destination->id, $destination->title); $dataWritten = file_put_contents($console->outputDir . DS . $fileName, $render->render(['destination' => $destination, 'taxonomyHandler' => $taxonomyHandler])); $destinationProcessedCount++; if ($dataWritten !== false) { $this->logger->info('destination file created - ' . $fileName); $destinationProcessedSuccessCount++; } else { $this->logger->error('failed to create destination file - ' . $fileName); } } $console->write(date('F j, Y, H:i:s') . " :: Processing finished.\n"); $console->write("Memory Usage: " . self::convert(memory_get_usage())); $console->write("Total Files Written: {$destinationProcessedSuccessCount}"); $console->write("Total Failed: " . ($destinationProcessedCount - $destinationProcessedSuccessCount)); $this->logger->info('Processing finished.'); $this->logger->info('Memory Usage: ' . self::convert(memory_get_usage())); $this->logger->info("Total Files Written: {$destinationProcessedSuccessCount}"); $this->logger->info('Total Failed: ' . ($destinationProcessedCount - $destinationProcessedSuccessCount)); } catch (\Exception $ex) { $message = $ex->getMessage() . "\n" . $ex->getTraceAsString(); $this->logger->debug($message); $console->close($message, Console::ERROR_OUT); } }
/** * 普通日志 * @param $api * @param $msg */ protected function infoLogs($api, $msg) { $this->logger->info($api . ":: " . $msg); }
<?php use Katzgrau\KLogger\Logger; require_once 'vendor/autoload.php'; $logger = new Logger(__DIR__ . "/logs"); $logger->info("Info example"); $errorInfo = array('code' => 404, 'message' => "Not Found"); $logger->error("Error example", $errorInfo);