Example #1
0
 /**
  * @param $message
  * @param string $type
  * @return $this
  */
 public function push($message, $type = Log::TYPE_MESSAGE)
 {
     $message = App::time('log')->date('Y-m-d H:i:s') . "\t" . print_r($message, 1) . "\n";
     if (++$this->hits > 5) {
         if (is_null($this->handle)) {
             $this->handle = fopen($this->fileName, 'a');
         }
         fwrite($this->handle, $message);
     } else {
         file_put_contents($this->fileName, $message, FILE_APPEND);
     }
     return $this;
 }
Example #2
0
 public function __construct(Settings $dsn = null)
 {
     $this->dsn = $dsn ? $dsn : new Settings();
     if (empty($dsn->proxyClient)) {
         throw new Exception('proxyClient required in dsn', Exception::PROXY_REQUIRED);
     }
     $this->table = new Symbol($dsn->path ? $dsn->path : 'key_value_storage');
     $this->keyField = new Symbol('k');
     $this->valueField = new Symbol('v');
     $this->expireField = new Symbol('e');
     $this->db = Database::getInstance($this->dsn->proxyClient);
     $this->time = App::time($this->dsn->dateSource);
     // TODO use getInstance after Date_Source refactoring
 }