Skip to content

Commit

Permalink
completed log
Browse files Browse the repository at this point in the history
  • Loading branch information
mkalkbrenner committed Jan 14, 2025
1 parent 50004a8 commit 1ac3560
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 17 deletions.
9 changes: 9 additions & 0 deletions modules/search_api_solr_log/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Search API Solr Log

This module provides an alternative to the DB Logger of Drupal Core.

After enabling the module, visit `/admin/config/search/search-api/server/search_api_solr_log_server/editSolr` and
configure the connection according to your needs.

Note, if you don't have a dedicated log server, you can use the identical settings of an existing server.
But it is important to activate "Advanced / Retrieve result data from Solr".
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ langcode: en
status: true
dependencies:
config:
- search_api.server.jt_price_list_solr_server
- search_api.server.search_api_solr_log_server
module:
- search_api_solr
third_party_settings:
Expand Down Expand Up @@ -157,4 +157,4 @@ options:
delete_on_fail: true
index_directly: false
track_changes_in_references: false
server: jt_price_list_solr_server
server: search_api_solr_log_server
Original file line number Diff line number Diff line change
Expand Up @@ -1608,8 +1608,8 @@ display:
label: User
exclude: false
alter:
alter_text: false
text: ''
alter_text: true
text: '{{ uid | raw}}'
make_link: false
path: ''
absolute: false
Expand Down Expand Up @@ -1659,6 +1659,28 @@ display:
multi_type: separator
multi_separator: ', '
format_plural_values: { }
pager:
type: full
options:
offset: 0
pagination_heading_level: h4
items_per_page: 50
total_pages: null
id: 0
tags:
next: 'Next ›'
previous: '‹ Previous'
first: '« First'
last: 'Last »'
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 25, 50'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
quantity: 9
filters:
index_id:
id: index_id
Expand Down Expand Up @@ -2114,6 +2136,7 @@ display:
type: fields
options: { }
defaults:
pager: false
style: false
row: false
fields: false
Expand Down
2 changes: 1 addition & 1 deletion modules/search_api_solr_log/search_api_solr_log.info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ core_version_requirement: ^10.2 || ^11.0
package: 'search_api'
configure: 'search_api_solr_log.settings'
dependencies:
- facets:better_exposed_filters
- facets:facets_exposed_filters
- search_api_solr:search_api_solr
- views:views
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
search_api_solr_log.clear_logs:
route_name: 'search_api_solr_log.clear_logs'
title: 'Clear'
appears_on:
- view.search_api_solr_log.overview

This file was deleted.

6 changes: 3 additions & 3 deletions modules/search_api_solr_log/search_api_solr_log.routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ search_api_solr_log.settings:
requirements:
_permission: 'administer site configuration'

search_api_solr_log.confirm:
path: '/admin/reports/search-api-solr-log/confirm'
search_api_solr_log.clear_logs:
path: '/admin/reports/search-api-solr-log/clear-logs'
defaults:
_form: '\Drupal\search_api_solr_log\Form\ClearLogConfirmForm'
_title: 'Confirm delete recent log messages'
requirements:
_permission: 'access site reports'
_permission: 'administer site configuration'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
services:
logger.solr:
class: Drupal\search_api_solr_log\Logger\SolrLogger
arguments: ['@entity_type.manager', '@logger.log_message_parser', '@solarium.query_helper']
arguments: ['@logger.log_message_parser', '@solarium.query_helper']
tags:
- { name: logger }
- { name: backend_overridable }
7 changes: 3 additions & 4 deletions modules/search_api_solr_log/src/Logger/SolrLogger.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ class SolrLogger implements LoggerInterface {
/**
* Constructor.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Logger\LogMessageParserInterface $parser
* The parser to use when extracting message variables.
* @param \Solarium\Core\Query\Helper $helper
* The solarium query helper
*/
public function __construct(
protected EntityTypeManagerInterface $entityTypeManager,
protected LogMessageParserInterface $parser,
protected Helper $helper,
) {}
Expand Down Expand Up @@ -123,7 +122,7 @@ public function log($level, string|\Stringable $message, array $context = []): v
public static function getConnector() : ?SolrConnectorInterface {
try {
$index = Index::load('search_api_solr_log');
if ($index && $index->isActive() && $index->hasValidServer()) {
if ($index && $index->hasValidServer() && $index->isServerEnabled()) {
if ($server = $index->getServerInstance()) {
$backend = $server->getBackend();
if ($backend instanceof SolrBackendInterface) {
Expand Down

0 comments on commit 1ac3560

Please sign in to comment.