Skip to content

Commit

Permalink
Merge pull request #120 from alleyinteractive/feature/full-logging
Browse files Browse the repository at this point in the history
Allow for unrestricted post logging
  • Loading branch information
srtfisher authored Apr 29, 2024
2 parents d5392fd + 4cdd608 commit c3344e6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
This library adheres to [Semantic Versioning](https://semver.org/) and [Keep a
CHANGELOG](https://keepachangelog.com/en/1.0.0/).

## Unreleased

### Added

- New filter `ai_logger_unrestricted_logging` to allow unrestricted logging
without checking if the log was recently seen.

## 2.3.2

- Add return types to logger to appease `psr/log` v3.
Expand Down
15 changes: 12 additions & 3 deletions inc/handler/class-post-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ protected function insert_permitted( string $transient_key, array $log ): bool {
return true;
}

/**
* Allow unrestricted logging if filtered.
*
* @param bool $unrestricted_logging Whether to allow unrestricted logging.
* @param array $log Log arguments.
*/
if ( \apply_filters( 'ai_logger_unrestricted_logging', false, $log ) ) {
return true;
}

/**
* The throttling transient has expired if get_transient returns false,
* and a new insert should be permitted.
Expand All @@ -242,9 +252,8 @@ protected function insert_permitted( string $transient_key, array $log ): bool {
}

/**
* Assign the terms associated with the new post, currently
* used to apply a Log Level (info, warning, error) and the
* custom context to a log
* Assign the terms associated with the new post, currently used to apply a
* Log Level (info, warning, error) and the custom context to a log
*
* @param int $new_post_id Post ID.
* @param string $term Term name.
Expand Down

0 comments on commit c3344e6

Please sign in to comment.