/** * Listen to Upload * * Observe Uploadable models for changes. Should be called from the boot() method. * @return void */ protected function listenToUpload() { if (!($model = $this->getModelClass())) { return; } if (Config::get('app.debug')) { Log::debug('Binding upload relationship caches', ['uploadable' => $model]); } $flush_uploadable = function ($uploadable) { $repository = $this->make($uploadable); $tags = $repository->getTags('uploads'); if (Config::get('app.debug')) { Log::debug('Flushing uploadable relationship caches', ['uploadable' => $repository->id, 'tags' => $tags]); } Cache::tags($tags)->flush(); }; $model::updated($flush_uploadable); $model::deleted($flush_uploadable); $flush_upload = function ($upload) use($model) { $repository = Upload::make($upload); $tags = $repository->getTags($model); if (Config::get('app.debug')) { Log::debug('Flushing upload relationship caches', ['model' => $model, 'tags' => $tags]); } Cache::tags($tags)->flush(); foreach ($this->withUpload($repository) as $uploadable) { $uploadable->getModel()->touch(); } }; $upload_model = Upload::getModelClass(); $upload_model::updated($flush_upload); $upload_model::deleted($flush_upload); }
public function boot() { if (!($model = $this->getModelClass())) { return; } parent::boot(); // Flush nested set caches related to the object if (Config::get('app.debug')) { Log::info('Binding heirarchical caches', ['model' => $model]); } // Trigger save events after move events // Flushing parent caches directly causes an infinite recursion $touch = function ($node) { if (Config::get('app.debug')) { Log::debug('Touching parents to trigger cache flushing.', ['parent' => $node->parent]); } // Force parent caches to flush if ($node->parent) { $node->parent->touch(); } }; $model::moved($touch); // Flush caches related to the ancestors $flush = function ($node) { $tags = $this->make($node)->getParentTags(); if (Config::get('app.debug')) { Log::debug('Flushing parent caches', ['tags' => $tags]); } Cache::tags($tags)->flush(); }; $model::saved($flush); $model::deleted($flush); }
public function update(Request $request) { $request_attributes = $this->validateAndReturn($request, $this->getValidationRules()); Log::debug("\$request_attributes=" . json_encode($request_attributes, 192)); PlatformAdminMeta::setMulti($request_attributes); return view('platformAdmin::xchain.settings.update', []); }
public function logToConsole($tx_event) { if ($_debugLogTxTiming = Config::get('xchain.debugLogTxTiming')) { PHP_Timer::start(); } if (!isset($GLOBALS['XCHAIN_GLOBAL_COUNTER'])) { $GLOBALS['XCHAIN_GLOBAL_COUNTER'] = 0; } $count = ++$GLOBALS['XCHAIN_GLOBAL_COUNTER']; $xcp_data = $tx_event['counterpartyTx']; if ($tx_event['network'] == 'counterparty') { if ($xcp_data['type'] == 'send') { $this->wlog("from: {$xcp_data['sources'][0]} to {$xcp_data['destinations'][0]}: {$xcp_data['quantity']} {$xcp_data['asset']} [{$tx_event['txid']}]"); } else { $this->wlog("[" . date("Y-m-d H:i:s") . "] XCP TX FOUND: {$xcp_data['type']} at {$tx_event['txid']}"); } } else { if (rand(1, 100) === 1) { $c = Carbon::createFromTimestampUTC(floor($tx_event['timestamp']))->timezone(new \DateTimeZone('America/Chicago')); $this->wlog("heard {$count} tx. Last tx time: " . $c->format('Y-m-d h:i:s A T')); } } if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for logToConsole: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } }
private function _getPlaceInfo() { $place = Places::getPlaceName($this->lat, $this->lng, $this->name); Log::debug($place); $this->status = self::IDENTIFIED; return $this; }
public function fire($job, $data) { // build the event data $event_data = $this->event_builder->buildBlockEventData($data['hash']); // fire an event try { Log::debug("Begin xchain.block.received {$event_data['height']} ({$event_data['hash']})"); Event::fire('xchain.block.received', [$event_data]); Log::debug("End xchain.block.received {$event_data['height']} ({$event_data['hash']})"); // job successfully handled $job->delete(); } catch (Exception $e) { EventLog::logError('BTCBlockJob.failed', $e, $data); // this block had a problem // but it might be found if we try a few more times $attempts = $job->attempts(); if ($attempts > self::MAX_ATTEMPTS) { // we've already tried MAX_ATTEMPTS times - give up Log::debug("Block {$data['hash']} event failed after attempt " . $attempts . ". Giving up."); $job->delete(); } else { $release_time = 2; Log::debug("Block {$data['hash']} event failed after attempt " . $attempts . ". Trying again in " . self::RETRY_DELAY . " seconds."); $job->release(self::RETRY_DELAY); } } }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { try { $response = $next($request); // always render exceptions ourselves if (isset($response->exception) and $response->exception) { throw $response->exception; } return $response; } catch (HttpResponseException $e) { // HttpResponseException can pass through throw $e; } catch (ValidationException $e) { $validator = $e->validator; $flat_errors = []; foreach ($validator->errors()->getMessages() as $errors) { $flat_errors = array_merge($flat_errors, array_values($errors)); } $response = new JsonResponse(['message' => "The request was not processed successfully. " . implode(" ", $flat_errors), 'errors' => $flat_errors], 422); return $response; } catch (Exception $e) { \Illuminate\Support\Facades\Log::debug("HandleAPIErrors caught " . get_class($e) . " " . $e->getMessage()); try { $error_trace = $this->getExceptionTraceAsString($e); } catch (Exception $other_e) { $error_trace = "FAILED getExceptionTraceAsString: " . $other_e->getMessage() . "\n\n" . $e->getTraceAsString(); } $this->event_log->logError('error.api.uncaught', $e, ['errorTrace' => $error_trace]); // catch any uncaught exceptions // and return a 500 response $response = new JsonResponse(['message' => 'Unable to process this request', 'errors' => ['Unexpected error']], 500); return $response; } }
/** * Store a newly created resource in storage. * @Get("/{provider}/callback", as="social.login.getLogin") * @param string $provider * @return \Illuminate\Http\Response */ public function getLogin($provider) { $userData = Socialite::with($provider)->user(); Log::debug(print_r($userData, true)); $user = User::firstOrCreate(['username' => $userData->nickname, 'email' => $userData->email]); Auth::login($user); return response()->redirectToRoute('articles.getIndex'); }
/** * Display a listing of the resource. * * @return Response */ public function index() { Log::info('infoメッセージ'); Log::debug('debugメッセージ'); Log::warning('warningメッセージ'); Log::error('errorメッセージ'); return view('welcome'); }
/** * Get all available channels from config * * @return array */ public function getChannels() { $configChannels = config('bow.log.channels'); if (count($configChannels) <= 0) { Log::debug('bow.log.channels is not configured'); } return $configChannels; }
/** * Create a new event instance. * * @return void */ public function __construct($jobResult, $userId, $userIpAddress) { // $this->jobResult = $jobResult; $this->userId = $userId; $this->userIpAddress = $userIpAddress; Log::debug('JobFinished Event fired'); }
private function getCssOutput($tmpHtmlFile) { if ($this->cssfile[0] === '/') { $this->cssfile = substr($this->cssfile, 1); } $cmd = $this->servicePath . ' ' . $tmpHtmlFile . ' -mc ' . $this->cssfile; Log::debug('AsyncCss Exec: ' . $cmd); return shell_exec($cmd); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { $response = $next($request); $age = $request->input('age'); Log::debug('age -> ' . $age); $rjb = $request->header('rjb', 'bar'); $response->headers->set('foo', $rjb); return $response; }
public function fire($job, $data) { try { $_debugLogTxTiming = Config::get('xchain.debugLogTxTiming'); // load from bitcoind if ($_debugLogTxTiming) { Log::debug("Begin {$data['txid']}"); } if ($_debugLogTxTiming) { PHP_Timer::start(); } $transaction_model = $this->bitcoin_transaction_store->getParsedTransactionFromBitcoind($data['txid']); $bitcoin_transaction_data = $transaction_model['parsed_tx']['bitcoinTx']; if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for getParsedTransactionFromBitcoind: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } // parse the transaction if ($_debugLogTxTiming) { PHP_Timer::start(); } $event_data = $this->transaction_data_builder->buildParsedTransactionData($bitcoin_transaction_data, $data['ts']); if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for buildParsedTransactionData: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } // fire an event if ($_debugLogTxTiming) { PHP_Timer::start(); } Event::fire('xchain.tx.received', [$event_data, 0, null, null]); if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for fire xchain.tx.received: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } // job successfully handled if ($_debugLogTxTiming) { PHP_Timer::start(); } $job->delete(); if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for job->delete(): " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } } catch (Exception $e) { EventLog::logError('BTCTransactionJob.failed', $e, $data); // this transaction had a problem // but it might be found if we try a few more times $attempts = $job->attempts(); if ($attempts > self::MAX_ATTEMPTS) { // we've already tried MAX_ATTEMPTS times - give up Log::debug("Transaction {$data['txid']} event failed after attempt " . $attempts . ". Giving up."); $job->delete(); } else { $release_time = 2; Log::debug("Transaction {$data['txid']} event failed after attempt " . $attempts . ". Trying again in " . self::RETRY_DELAY . " seconds."); $job->release(self::RETRY_DELAY); } } }
public function handle() { $token = Seat::get('slack_token'); if ($token == null) { throw new SlackSettingException("missing slack_token in settings"); } // call rtm method in order to get a fresh new WSS uri $api = new SlackApi($token); $wss = $api->rtmStart(); // start a loop event which will handle RTM daemon $loop = Factory::create(); $connector = new Connector($loop); // prepare the event catcher (we only care about members join and channels) $connector($wss)->then(function (WebSocket $conn) { // trigger on RTM message event $conn->on('message', function (MessageInterface $msg) use($conn) { // since Slack RTM return json message, decode it first $slackMessage = json_decode($msg, true); // then, process to channel, groups and member case switch ($slackMessage['type']) { // if the event is of type "team_join", then update our Slack user table using the new slack user id // common element between SeAT and Slack is mail address case 'team_join': $this->newMember($slackMessage['user']); break; // if the event is of type "channel_created" // then update our Slack channel table using new slack channel id // if the event is of type "channel_created" // then update our Slack channel table using new slack channel id case 'group_joined': case 'channel_created': $this->createChannel($slackMessage['channel']); break; // if the event is of type "channel_delete", then remove the record from our Slack channel table // if the event is of type "channel_delete", then remove the record from our Slack channel table case 'channel_deleted': case 'group_archive': SlackChannel::destroy($slackMessage['channel']); break; case 'group_unarchive': Log::debug('[Slackbot][Daemon][group_unarchive] ' . print_r($slackMessage, true)); $this->restoreGroup($slackMessage['channel']); break; case 'channel_rename': case 'group_rename': $this->renameChannel($slackMessage['channel']); break; } }); }, function (\Exception $e) use($loop) { echo $e->getMessage(); $loop->stop(); }); $loop->run(); return; }
/** * Register any other events for your application. * * @param \Illuminate\Contracts\Events\Dispatcher $events * @return void */ public function boot(DispatcherContract $events) { parent::boot($events); // Event::listen('Pizzeria\\Events\\OrderCreated', function ($event) { // Handle the event... Log::debug('EventServiceProvider::boot [Pizzeria\\Events\\OrderCreated] - got the event message: '); Log::debug($event->getMessage()); }); }
/** * Register the service provider. * * @return void */ public function register() { $this->app->bind('Tokenly\\SwapbotClient\\SwapbotClient', function ($app) { $config = $this->bindConfig(); \Illuminate\Support\Facades\Log::debug("\$config=" . json_encode($config, 192)); \Illuminate\Support\Facades\Log::debug("nv('SWAPBOT_CONNECTION_URL', 'http://swapbot.tokenly.com')=" . json_encode(env('SWAPBOT_CONNECTION_URL', 'http://swapbot.tokenly.com'), 192)); $swapbot_client = new \Tokenly\SwapbotClient\SwapbotClient($config['swapbot.connection_url']); return $swapbot_client; }); }
/** * Handle a canceled subscription from Braintree. * * @param Braintree_WebhookNotification $payload * * @return \Symfony\Component\HttpFoundation\Response */ protected function handleSubscriptionCanceled(Braintree_WebhookNotification $payload) { Log::debug('We are running subscriptionCanceled handle'); if ($payload->subscription->id) { if ($subscription = $this->getSubscription($payload->subscription->id)) { $subscription->subscription()->refresh(); } } Log::debug('Finish Webhook.'); return new Response('Webhook Handled', 200); }
public function handleNewBlock($block_event) { $block_handler = $this->network_handler_factory->buildBlockHandler($block_event['network']); if ($_debugLogTxTiming = Config::get('xchain.debugLogTxTiming')) { PHP_Timer::start(); } $result = $block_handler->handleNewBlock($block_event); if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for handleNewBlock: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } return $result; }
public function updating(Tournament $model) { $dirtyStatus = array_get($model->getDirty(), 'status'); if (Tournament::STATUS_STARTED === $dirtyStatus && 1 > $model->matches()->getResults()->count()) { Log::debug('Tournament ' . $model->name . ' was started'); event(new TournamentWasStarted($model)); } if (Tournament::STATUS_DRAFT === $dirtyStatus) { Log::debug('Tournament ' . $model->name . ' was reset'); event(new TournamentWasReset($model)); } }
/** * * 统一下单,WxPayUnifiedOrder中out_trade_no、body、total_fee、trade_type必填 * appid、mchid、spbill_create_ip、nonce_str不需要填入 * @param WxPayUnifiedOrder $inputObj * @param int $timeOut * @throws WxException * @return 成功时返回,其他抛异常 */ public static function unifiedOrder($inputObj, $timeOut = 6) { $url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; //检测必填参数 if (!$inputObj->IsOut_trade_noSet()) { throw new WxException("缺少统一支付接口必填参数out_trade_no!"); } else { if (!$inputObj->IsBodySet()) { throw new WxException("缺少统一支付接口必填参数body!"); } else { if (!$inputObj->IsTotal_feeSet()) { throw new WxException("缺少统一支付接口必填参数total_fee!"); } else { if (!$inputObj->IsTrade_typeSet()) { throw new WxException("缺少统一支付接口必填参数trade_type!"); } } } } //关联参数 if ($inputObj->GetTrade_type() == "JSAPI" && !$inputObj->IsOpenidSet()) { throw new WxException("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"); } if ($inputObj->GetTrade_type() == "NATIVE" && !$inputObj->IsProduct_idSet()) { throw new WxException("统一支付接口中,缺少必填参数product_id!trade_type为JSAPI时,product_id为必填参数!"); } //异步通知url未设置,则使用配置文件中的url if (!$inputObj->IsNotify_urlSet()) { $inputObj->SetNotify_url(PayConfig::NOTIFY_URL); //异步通知url } $inputObj->SetAppid(PayConfig::APPID); //公众账号ID $inputObj->SetMch_id(PayConfig::MCHID); //商户号 $inputObj->SetSpbill_create_ip($_SERVER['REMOTE_ADDR']); //终端ip //$inputObj->SetSpbill_create_ip("1.1.1.1"); $inputObj->SetNonce_str(self::getNonceStr()); //随机字符串 //签名 $inputObj->SetSign(); $xml = $inputObj->ToXml(); Log::debug('inputObj:' . $xml); $startTimeStamp = self::getMillisecond(); //请求开始时间 $response = self::postXmlCurl($xml, $url, false, $timeOut); $result = PayResults::Init($response); self::reportCostTime($url, $startTimeStamp, $result); //上报请求花费时间 return $result; }
protected function hook_post_unmanaged_addresses($call_data, $return_value) { $address_id = $return_value['id']; Log::debug("hook_unmanaged_addresses \$address_id={$address_id}"); $xchain_balances = PlatformAdminMeta::get('xchain_balances'); if (!$xchain_balances) { $xchain_balances = []; } $default_balances = ['BTC' => 0]; $xchain_balances[$address_id] = ['id' => $address_id, 'address' => $return_value['address'], 'balances' => $default_balances]; // set and update mock balances PlatformAdminMeta::set('xchain_balances', $xchain_balances); $this->updateXChainMockBalances(); }
/** * Execute the console command. * * @return mixed */ public function fire() { $user_repository = app('Tokenly\\LaravelApiProvider\\Contracts\\APIUserRepositoryContract'); Log::debug("\$user_repository is " . get_class($user_repository)); $user_vars = ['username' => $this->argument('username'), 'email' => $this->argument('email'), 'confirmed_email' => $this->argument('email'), 'password' => $this->argument('password'), 'privileges' => ['platformAdmin' => true]]; $user_model = $user_repository->create($user_vars); // log EventLog::log('user.platformAdmin.cli', $user_model, ['id', 'username', 'email']); // show the new user $user = clone $user_model; $user['password'] = '******'; $this->line(json_encode($user, 192)); $this->comment('Done.'); }
/** * Creates a new Auja instance. * * @param Application $app The Illuminate Application instance. * @param AujaConfigurator $aujaConfigurator * @param [] $models The model configuration. */ function __construct(Application $app, AujaConfigurator $aujaConfigurator, array $modelNames) { if (php_sapi_name() == 'cli') { /* Don't run when we're running artisan commands. */ return; } if (empty($modelNames)) { throw new \InvalidArgumentException('Provide models for Auja to manage'); } $this->app = $app; Log::debug('Initializing Auja with models:', $modelNames); $this->aujaConfigurator = $aujaConfigurator; $this->aujaConfigurator->configure($modelNames); }
public function pushEvent($tx_event) { $xcp_data = $tx_event['counterpartyTx']; $source = $tx_event['sources'] ? $tx_event['sources'][0] : null; $destination = $tx_event['destinations'] ? $tx_event['destinations'][0] : null; $quantity = isset($tx_event['values'][$destination]) ? $tx_event['values'][$destination] : null; $notification = ['txid' => $tx_event['txid'], 'network' => $tx_event['network'], 'type' => $tx_event['network'] == 'counterparty' ? $tx_event['counterPartyTxType'] : 'bitcoin', 'quantity' => $quantity, 'asset' => $tx_event['asset'], 'source' => $source, 'destination' => $destination]; if ($_debugLogTxTiming = Config::get('xchain.debugLogTxTiming')) { PHP_Timer::start(); } $this->pusher->send('/tx', $notification); if ($_debugLogTxTiming) { Log::debug("[" . getmypid() . "] Time for pushEvent: " . PHP_Timer::secondsToTimeString(PHP_Timer::stop())); } }
public function NotifyProcess($data, &$msg) { Log::debug('call back:' . json_encode($data)); $notfiyOutput = array(); if (!array_key_exists('transaction_id', $data)) { $msg = '输入参数不正确'; return false; } //查询订单,判断订单真实性 if (!$this->Queryorder($data['transaction_id'])) { $msg = '订单查询失败'; return false; } //event(new ) return true; }
private function initPayOrder($order) { $native = new NativePay(); $input = new UnifiedOrder(); $input->SetBody("邂逅行-" . $order->activity->title); $input->SetDetail($order->activity->description); $input->SetAttach("邂逅行"); $input->SetOut_trade_no($order->code); $input->SetTotal_fee($order->amount * 100); $input->SetTime_start(date("YmdHis")); $input->SetTime_expire(date("YmdHis", time() + 600)); $input->SetNotify_url(Config::get('consts.wepay_notify')); $input->SetTrade_type("NATIVE"); $input->SetProduct_id($order->id); $result = $native->GetPayUrl($input); Log::debug($result); return $result; }
protected function refreshAllBalances() { // find all addresses by id $xchain = app('Tokenly\\XChainClient\\Client'); $xchain_balances = PlatformAdminMeta::get('xchain_balances', []); foreach ($xchain_balances as $xchain_balance) { Log::debug("refreshAllBalances \$xchain_balance['id']=" . json_encode($xchain_balance['id'], 192)); foreach (Address::where('xchain_address_id', $xchain_balance['id'])->get() as $address) { // delete all balances Log::debug("deleting from address_balances WHERE address_id={$address->id}"); DB::table('address_balances')->where('address_id', $address->id)->delete(); // update balances $balances = $xchain->getBalances($address->address, true); if ($balances and count($balances) > 0) { Address::updateAddressBalances($address->id, $balances); } } } }
/** * Execute the job. * @param Mailer $mailer * @return void */ public function handle(Mailer $mailer) { $data = $this->data; Log::info('direct mail send start.'); // 実行試行回数のチェック if ($this->attempts() < 3) { // 再実行可能にするまで待機する秒数を指定 $this->release(10); $title = $data['name'] . 'さんからメールが届きました'; $replay = $data['email']; Log::debug(sprintf('to:%s, title: %s, replyTo: %s, body: %s', $this->article->mail, $title, $replay, $data['body'])); $mailer->send('mail.direct_send_mail', ['data' => $data], function ($message) use($title, $replay) { $message->to($this->article->mail)->subject($title)->bcc(env('MAIL_FROM_ADDRESS'))->replyTo($replay); }); Log::info('direct mail send complete.'); } else { Log::info('direct mail send reply:' . $this->attempts()); } }
public function setViewCountBatch($className, $action, $amount) { $userCounters = UserCounter::ofClassName($className)->where('action', 'view')->get(); foreach ($userCounters as $object) { $cacheName = $this->getCacheName($object); Log::debug($cacheName . ' ' . $amount); switch ($action) { case 'plus': $count = Cache::increment($cacheName, $amount); break; case 'minus': $count = Cache::decrement($cacheName, $amount); if ($count < 0) { Cache::put($cacheName, 0); } break; } } return false; }