Plugin to store own logs for custom plugins.
It contains public endpoint that accept HTTP request in order to use it from JS files. Also this can be implemented from other PHP files.
You can also use this repo as Arcadier plugin base template.
The file structure of each Plug-in's source code:
├── admin
├── ADevTools
├── CustomLog
├── html
├── css
└── scripts
└── php files
├── user
├── html
├── css
└── scripts
└── php files
admin folder contains the part of the code that executes for the marketplace administrator.
user folder has the code that executes for the merchants and buyers.
ADevTools folder is where we can have more custom functionality that can be reuse in other plugins.
First you need to configure in Arcadier's Developer Dashboard some Custom Tables:
Column Name | Column Type | Description |
---|---|---|
Id | Guid | Arcadier unique identifier. |
EmailFrom | String | Email from you are going to receive the email. |
Emails | String | Emails who will receive the error.(separated by comma) |
EmailSubject | String | Email Subject. |
SendEmail | Integer | 0 - not send email 1 - to send email |
Once table is defined please create only one configuration using the arcadier's api.
Should look like this
Column Name | Column Type | Description |
---|---|---|
Id | Guid | Arcadier unique identifier. |
File | String | File name who is generating the error. |
Message | String | Message that you want to log into the table |
Payload | String | JSON payload to be store |
Should look like this
Configure public endpoint with correct marketplace credentials
Is requiere to change to the correct markatplace credentials in the Logger.php file.
$customLogger = new CustomLogger('CLIENT ID','CLIENT SECRET');// credentials from your marketplace
Endpoint Url
https://{{your-marketplace}}.arcadier.io/user/plugins/{{plugin-ID}}/Logger.php
Column Name | Required | Description |
---|---|---|
Message | YES | Descriptive error message. |
FileName | NO | File name who invoke the method |
Payload | YES | JSON payload to be store |
EmailBody | NO | Email body that you want to send also the flag in the configuration table should be enable (1) |
Request Payload
{
"Message": "message error to log",
"FileName": "xyz.php",
"Payload": {
"prop1": "something",
"prop2": "something prop 2",
"prop3": 777,
"prop4": "something prop 4",
"prop5": 100
},
"EmailBody": "<p>Some error happen during test</p>"
}
Response result
"{\"Result\" : true }"
JS example request
var settings = {
"url": "https://{{your-marketplace}}.arcadier.io/user/plugins/{{plugin-ID}}/Logger.php",
"method": "POST",
"timeout": 0,
"headers": {
"Content-Type": "application/json"
},
"data": JSON.stringify({
"Message": "message error to log",
"FileName": "xyz.php",
"Payload": {
"prop1": "something",
"prop2": "something prop 2",
"prop3": 777,
"prop4": "something prop 4",
"prop5": 100
},
"EmailBody": "<p>Some error happen during test</p>"
}),
};
$.ajax(settings).done(function (response) {
console.log(response);
});
Create a new PHP file and add the next statement.
include('../admin/ADevTools/CustomLog/CustomLogger.php');
$customLogger = new CustomLogger('CLIENT ID','CLIENT SECRET');// credentials from your marketplace
$customLogger->Log($Payload, $Message, $FileName, $EmailBody);
Create a new PHP file and add the next statements.
include('ADevTools/CustomLog/CustomLogger.php');
$customLogger = new CustomLogger('CLIENT ID','CLIENT SECRET');// credentials from your marketplace
$customLogger->Log($Payload, $Message, $FileName, $EmailBody);
- Download repository.
- Compress (.zip) the admin and user folder.
- Login to Arcadier Plug-in Developer Dashboard.
- Create a new Plug-in.
- Create custom tables and custom field (if needed).
- Upload .zip file in the created Plug-in.
- Login into your marketplace admin portal.
- Go to Plug-in
- Search for the Plug-in and install it.