- replaced logMessage() with ManiaControl->log

- Moved Chatlog DATE constant into plugin class
This commit is contained in:
Steffen Schröder 2013-12-31 18:24:40 +01:00
parent 35c1bf0c08
commit 2c4920ce8a
3 changed files with 7 additions and 7 deletions

View File

@ -64,7 +64,6 @@ class ManiaControl implements CommandListener {
*/ */
const VERSION = '0.01'; const VERSION = '0.01';
const API_VERSION = '2013-04-16'; const API_VERSION = '2013-04-16';
const DATE = 'd-m-y h:i:sa T';
/** /**
* Public properties * Public properties
@ -183,7 +182,7 @@ class ManiaControl implements CommandListener {
$this->client->Terminate(); $this->client->Terminate();
} }
logMessage('Quitting ManiaControl!'); $this->log('Quitting ManiaControl!');
exit(); exit();
} }
@ -191,7 +190,7 @@ class ManiaControl implements CommandListener {
* Run ManiaControl * Run ManiaControl
*/ */
public function run() { public function run() {
logMessage('Starting ManiaControl v' . self::VERSION . '!'); $this->log('Starting ManiaControl v' . self::VERSION . '!');
// Load plugins // Load plugins
$this->pluginManager->loadPlugins(); $this->pluginManager->loadPlugins();

View File

@ -287,14 +287,14 @@ class Server {
$waitBegin = time(); $waitBegin = time();
$maxWaitTime = 20; $maxWaitTime = 20;
$lastStatus = $response['Name']; $lastStatus = $response['Name'];
logMessage("Waiting for server to reach status {$statusCode}..."); $this->maniaControl->log("Waiting for server to reach status {$statusCode}...");
logMessage("Current Status: {$lastStatus}"); $this->maniaControl->log("Current Status: {$lastStatus}");
while ($response['Code'] !== 4) { while ($response['Code'] !== 4) {
sleep(1); sleep(1);
$this->maniaControl->client->query('GetStatus'); $this->maniaControl->client->query('GetStatus');
$response = $this->maniaControl->client->getResponse(); $response = $this->maniaControl->client->getResponse();
if ($lastStatus !== $response['Name']) { if ($lastStatus !== $response['Name']) {
logMessage("New Status: " . $response['Name']); $this->maniaControl->log("New Status: " . $response['Name']);
$lastStatus = $response['Name']; $lastStatus = $response['Name'];
} }
if (time() - $maxWaitTime > $waitBegin) { if (time() - $maxWaitTime > $waitBegin) {

View File

@ -16,6 +16,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
*/ */
const ID = 1; const ID = 1;
const VERSION = 0.1; const VERSION = 0.1;
const DATE = 'd-m-y h:i:sa T';
const SETTING_FOLDERNAME = 'Log-Folder Name'; const SETTING_FOLDERNAME = 'Log-Folder Name';
const SETTING_FILENAME = 'Log-File Name'; const SETTING_FILENAME = 'Log-File Name';
const SETTING_USEPID = 'Use Process-Id for File Name'; const SETTING_USEPID = 'Use Process-Id for File Name';
@ -148,7 +149,7 @@ class ChatlogPlugin implements CallbackListener, Plugin {
if (!$login) { if (!$login) {
$login = ''; $login = '';
} }
$message = date(ManiaControl::DATE) . " >> {$login}: {$text}" . PHP_EOL; $message = date(self::DATE) . " >> {$login}: {$text}" . PHP_EOL;
file_put_contents($this->fileName, $message, FILE_APPEND); file_put_contents($this->fileName, $message, FILE_APPEND);
} }
} }