This project is not covered by Drupal’s security advisory policy.

# dblogall

The dblogall module is a drop-in replacement for the default dblog module in Drupal. It replicates all the functionality
of the core dblog module while adding additional features and columns to the log table.

## Features

- Logs all Drupal system events and messages to the database log table.
- Provides a dedicated administration page at `/admin/reports/dblogall` to view and manage log messages.
- Supports grouping of log messages based on the `group` column.
- Uses the same database table name (`watchdog`) as the core dblog module to facilitate a seamless transition.
- Admin form that allows you to change the default PSR Logger in Drupal via config.
- Additional columns (`debug` and `data`) are added to store debug information and additional data in JSON format.
- Integration with Monolog (still in progress)

## Grouping

An additional Column is added to the watchdog database table (modifies core table in a safe way, does not uninstall when
uninstalling the module) varchar -

It processes this value (what gets populated in it) is from the placeholders "group"

$logger->info($message, ['group' => 'mygroup']);

## Requirements

- Drupal 8.x || 9.x || 10.x

## Installation

1. Download the dblogall module and place it in your Drupal installation's `modules/custom` directory.
2. Enable the dblogall module either through the Drupal administration UI or by running the following Drush
command: `drush en dblogall`.

## Configuration

1. Once the module is enabled, navigate to the Administration > Configuration > Development > Logging
page (`/admin/config/development/logging`) in your Drupal site.
2. In the "Loggers" section, you can select the "Dblogall Logger" as the default logger to replace the core dblog.
Click "Save configuration" to apply the changes.
3. To revert back to the core dblog module, simply select the "Database Log" as the default logger and click "Save
configuration".

## Usage

Once the dblogall module is enabled and configured as the default logger, all Drupal system events, errors, and messages
will be logged to the `watchdog` table in the database. You can view and manage these log messages by visiting
the `/admin/reports/dblogall` page.

### Logging Custom Messages

To log custom messages from your custom modules, you can use the `dblogall_logger` service provided by the dblogall
module. Here's an example of how to use it:

```php
use Drupal\Core\Logger\LoggerChannelFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* Your custom module class.
*/
class YourCustomModuleClass {

/**
* The logger service.
*
* @var \Drupal\Core\Logger\LoggerChannelInterface
*/
protected $logger;

/**
* Constructs a new YourCustomModuleClass object.
*
* @param \Drupal\Core\Logger\LoggerChannelFactoryInterface $logger_factory
* The logger factory service.
*/
public function __construct(LoggerChannelFactoryInterface $logger_factory) {
$this->logger = $logger_factory->get('dblogall_logger');
}

/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('logger.factory')
);
}

/**
* Logs a custom message.
*/
public function logCustomMessage() {
$message = 'This is a custom log message.';
$severity = 'notice'; // Use one of the severity levels: 'debug', 'info', 'notice', 'warning', 'error', 'critical', 'alert', 'emergency'.
$context = ['custom_key' => 'custom_value']; // Additional context data, if required.

$this->logger->log($severity, $message, $context);
}

}

Supporting organizations: 

Project information

Releases