Ejemplo n.º 1
0
 /**
  * Create a new thread if $threadId is not already running
  * 
  * @param string $threadId
  * @return X_Threads_Thread_Info|X_Threads_Thread
  */
 public function newThread($threadId)
 {
     $thread = $this->getMonitor()->getThread($threadId);
     if ($thread->getState() == X_Threads_Thread_Info::STOPPED) {
         // create a new thread and return it
         $thread = new X_Threads_Thread($threadId, $this);
         if (!$this->isLogger()) {
             $thread->setLogger(new X_Threads_Logger_Null());
         } else {
             $thread->setLogger(new X_Threads_Logger_File("vlcShares.thread-{$threadId}.log", X_Debug::getLogPath()));
             // redirect standard debug too if enabled
             if (X_Debug::isEnabled()) {
                 X_Debug::i("Forking debug log to {" . X_Debug::getLogPath() . "/vlcShares.thread-{$threadId}.log");
                 X_Debug::init(X_Debug::getLogPath() . "/vlcShares.thread-{$threadId}.log", X_Debug::getLevel());
             }
         }
     }
     return $thread;
 }
Ejemplo n.º 2
0
 public function log($msg)
 {
     if ($this->logger == null) {
         // initialize default logger
         $this->setLogger(new X_Threads_Logger_File("vlcShares.thread-{$this->getId()}.log", sys_get_temp_dir()));
         // redirect standard debug too if enabled
         if (X_Debug::isEnabled()) {
             X_Debug::init(sys_get_temp_dir() . "/vlcShares.thread-{$this->getId()}.log", X_Debug::getLevel());
         }
     }
     $this->logger->log($msg);
 }