Skip to content

Commit

Permalink
logging docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zcwilt committed Jul 28, 2024
1 parent 46c87f7 commit cff8094
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 0 deletions.
43 changes: 43 additions & 0 deletions content/dev/modules/base/languagedefines/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,46 @@ The documentation in this section is Work in progress and relates to features th

# Introduction

Language define files for modules follow the same format as normal language defines.

They are stored in `includes/languages/{language}/modules/` and at the very least should have an english translation.

e.g.

`includes/languages/english/modules/payment/lang.cod.php`

`includes/languages/english/modules/shipping/lang.flat.php`

`includes/languages/english/modules/order_total/lang.ot_subtotal.php`


Like module configuration keys, naming of module language defines are the same
e.g.

`MODULE_[module type]\_[module name]\_[define name]`

There are some other rules.

language define names should be unique and not match any other module configuration defines.

At a minimum you should provide the following

'TEXT_TITLE' => 'Stripe Checkout',

'TEXT_DESCRIPTION' => '<strong>Stripe Pay</strong>',


e.g

```
$define = [
'MODULE_PAYMENT_STRIPE_PAY_TEXT_TITLE' => 'Stripe Checkout',
'MODULE_PAYMENT_STRIPE_PAY_TEXT_DESCRIPTION' => '<strong>Stripe Pay</strong>',
];
return $define;
```

Note: also if you want to provide a different tiile in the admin interface you can add something like

`MODULE_PAYMENT_STRIPE_PAY_ADMIN_TEXT_TITLE' => 'Stripe Checkout(ADMIN)`

83 changes: 83 additions & 0 deletions content/dev/modules/base/logging/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,86 @@ The documentation in this section is Work in progress and relates to features th

# Introduction

All modules have access to a new logging infrastructure.

This logging infrastructure uses monolog as the log provider.

It provides 3 log handlers

- File logging
- Console logging
- Email Logging

To log an something in a module you can do

`$this->logger->log($logLevel, $message, $context)`

$logLevel is based on the standard log levels that PSR/log supports.

i.e

```
class LogLevel
{
const EMERGENCY = 'emergency';
const ALERT = 'alert';
const CRITICAL = 'critical';
const ERROR = 'error';
const WARNING = 'warning';
const NOTICE = 'notice';
const INFO = 'info';
const DEBUG = 'debug';
}
```

$context is not required but if passed, should be an array of values.

## File logging

This logs the message and context(if passed) to a file.

Logs all messages with a level of `debug` or higher.

The file name that is used is determined as follows.

A prefix will be generated based on the log channel, which is based on the module type.

e.g. payment/shipping/order_total.

The code of the module is then added.

e.g. `flat` or `paypal` etc.

following this a string will be added based on whether the code generating the log is either admin or storefront code.

The log file name will then be suffixed with the current date using a format that means logs will be aggregated daily.

### For logs generated by Admin code.

This will be prefixed with `admin-`

and the current session admin id will be added if applicable.

Then if the code generating the error references an order, the order id will be added.

### For logs generated by store front code.

This will be prefixed with `store-`

Then if a customer id is available in the context of the log then the customer id, and a partial customer first name and last name will be added to the log file name.


## Console Logging

This will log the error message and context(if passed) to the javasript console.

So will be viewable using your browsers developer console.

Logs all messages with a level of `debug` or higher.

## Email Logging

This will send an email to the email address of the store owner. Currently there is no way to change this but that might change in the future.

Logs all messages with a level of `error` or higher.

0 comments on commit cff8094

Please sign in to comment.