Esempio n. 1
0
 /**
  * Writes the record down to the log of the implementing handler.
  *
  * @param array $record
  *
  * @return void
  */
 protected function write(array $record)
 {
     if (!$this->initialized) {
         if (!$this->initialize()) {
             return;
         }
     }
     $developer = new Developer($this->pastebin['api_key']);
     $account = new Account(new Credentials($this->pastebin['username'], $this->pastebin['password']));
     $draft = new Draft();
     $draft->setContent(json_encode($record, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
     $draft->setOwner($account);
     $draft->setVisibility(Visibility::VISIBILITY_UNLISTED);
     $draft->setFormat(Format::fromExtension('js'));
     $draft->setExpiry('24H');
     $draft->setTitle($record['datetime']->format('U'));
     $paste = $draft->paste($developer);
     $message = substr($record['formatted'], 0, 256);
     $this->channel->sendMessage("Error: \n\n```\n{$message}\n```\n\nPastebin: <{$paste->getUrl()}>");
 }
Esempio n. 2
0
 /**
  * Create a new draft with an account's default settings, and set them as the owner.
  * @param \Brush\Accounts\Account $account The owner's account whose settings to use.
  * @param \Brush\Accounts\Developer $developer The developer account to use if settings need to be retrieved.
  * @return \Brush\Pastes\Draft The created draft paste.
  */
 public static function fromOwner(Account $account, Developer $developer)
 {
     $draft = new Draft();
     $draft->setOwner($account);
     User::fromAccount($account, $developer)->getDefaults()->applyTo($draft);
     return $draft;
 }