Skip to content

alexdelgado0792/Arcadier-CustomLogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Arcadier-CustomLogger Description

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.

File structure

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.


Custom Tables

First you need to configure in Arcadier's Developer Dashboard some Custom Tables:

Configuration

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


custom table configuration

Log

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


custom table log


How to use public endpoint

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);
});

Implementing in user side

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);

Implementing in admin side

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);

How to install plugin in Arcadier Developer Dashboard

  1. Download repository.
  2. Compress (.zip) the admin and user folder.
  3. Login to Arcadier Plug-in Developer Dashboard.
  4. Create a new Plug-in.
  5. Create custom tables and custom field (if needed).
  6. Upload .zip file in the created Plug-in.
  7. Login into your marketplace admin portal.
  8. Go to Plug-in
  9. Search for the Plug-in and install it.

About

Plugin to store own logs from custom plugins

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages