Device Log to Server Log
This commit is contained in:
parent
98c603494d
commit
7df378d794
@ -8,9 +8,8 @@ class EndpointsApi extends ApiController{
|
|||||||
$command = "null";
|
$command = "null";
|
||||||
|
|
||||||
//Log
|
//Log
|
||||||
$logManager = new LogManager();
|
|
||||||
$logManager->setLevel(LOGLEVEL);
|
|
||||||
$logManager = new LogManager('../logs/api/'. date("Y-m-d").'.log');
|
$logManager = new LogManager('../logs/api/'. date("Y-m-d").'.log');
|
||||||
|
$logManager->setLevel(LOGLEVEL);
|
||||||
|
|
||||||
//Token Checks
|
//Token Checks
|
||||||
if ($obj['token'] == null || !isset($obj['token'])) {
|
if ($obj['token'] == null || !isset($obj['token'])) {
|
||||||
@ -62,7 +61,7 @@ class EndpointsApi extends ApiController{
|
|||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Diagnostic/Log Data Save
|
//Diagnostic
|
||||||
if (isset($obj['settings'])){
|
if (isset($obj['settings'])){
|
||||||
$data = ['mac' => $obj['settings']["network"]["mac"], 'ip_address' => $obj['settings']["network"]["ip"]];
|
$data = ['mac' => $obj['settings']["network"]["mac"], 'ip_address' => $obj['settings']["network"]["ip"]];
|
||||||
if (array_key_exists("firmware_hash", $obj['settings'])) {
|
if (array_key_exists("firmware_hash", $obj['settings'])) {
|
||||||
@ -75,6 +74,16 @@ class EndpointsApi extends ApiController{
|
|||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Log Data Save
|
||||||
|
if (isset($obj['logs'])){
|
||||||
|
foreach ($deviceLogs as $log) {
|
||||||
|
$logManager = new LogManager('../logs/devices/'. date("Y-m-d").'.log');
|
||||||
|
$logManager->setLevel(LOGLEVEL);
|
||||||
|
$logManager->write("[Device Log Msg] Device_ID " . $deviceId . "->" . $log, LogRecordType::ERROR);
|
||||||
|
unset($logManager);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Issuing command
|
// Issuing command
|
||||||
if ($command == "null"){
|
if ($command == "null"){
|
||||||
$device = DeviceManager::getDeviceByToken($obj['token']);
|
$device = DeviceManager::getDeviceByToken($obj['token']);
|
||||||
@ -148,7 +157,7 @@ class EndpointsApi extends ApiController{
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (count(SubDeviceManager::getAllSubDevices($deviceId)) == 0) {
|
if (count(SubDeviceManager::getAllSubDevices($deviceId)) == 0) {
|
||||||
SubDeviceManager::create($deviceId, 'on/off', UNITS[$key]);
|
//SubDeviceManager::create($deviceId, 'on/off', UNITS[$key]);
|
||||||
//RecordManager::create($deviceId, 'on/off', 0);
|
//RecordManager::create($deviceId, 'on/off', 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,5 +186,6 @@ class EndpointsApi extends ApiController{
|
|||||||
|
|
||||||
$this->response($jsonAnswer);
|
$this->response($jsonAnswer);
|
||||||
// this method returns response as json
|
// this method returns response as json
|
||||||
|
unset($logManager)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ class UpdatesApi {
|
|||||||
header('Content-type: text/plain; charset=utf8', true);
|
header('Content-type: text/plain; charset=utf8', true);
|
||||||
$logManager = new LogManager('../logs/ota/'. date("Y-m-d").'.log');
|
$logManager = new LogManager('../logs/ota/'. date("Y-m-d").'.log');
|
||||||
$logManager->setLevel(LOGLEVEL);
|
$logManager->setLevel(LOGLEVEL);
|
||||||
$logManager->write("[Updater] Client Connected", LogRecordTypes::WARNING);
|
$logManager->write("[Updater] Client Connected", LogRecordTypes::INFO);
|
||||||
|
|
||||||
|
|
||||||
//Filtrování IP adress
|
//Filtrování IP adress
|
||||||
@ -42,7 +42,7 @@ class UpdatesApi {
|
|||||||
$deviceName = $device['name'];
|
$deviceName = $device['name'];
|
||||||
$deviceId = $device['device_id'];
|
$deviceId = $device['device_id'];
|
||||||
//logfile write
|
//logfile write
|
||||||
$logManager->write("[Device] device_ID " . $deviceId . " was just updated to new version", LogRecordTypes::WARNING);
|
$logManager->write("[Device] device_ID " . $deviceId . " was just updated to new version", LogRecordTypes::INFO);
|
||||||
$logManager->write("[Device] version hash: " . md5_file($localBinary), LogRecordTypes::INFO);
|
$logManager->write("[Device] version hash: " . md5_file($localBinary), LogRecordTypes::INFO);
|
||||||
//notification
|
//notification
|
||||||
$notificationMng = new NotificationManager;
|
$notificationMng = new NotificationManager;
|
||||||
|
Loading…
Reference in New Issue
Block a user