Skip to content

Switch to using domain filtering not log_type#483

Merged
martinsumner merged 9 commits into
develop-3.4from
mas-d34-or.i4-domain
Nov 19, 2025
Merged

Switch to using domain filtering not log_type#483
martinsumner merged 9 commits into
develop-3.4from
mas-d34-or.i4-domain

Conversation

@martinsumner

Copy link
Copy Markdown
Owner

This looks like it is a more correct way of doing this.

Given we have no agreed hierarchy as part of OpenRiak, will use [backend, leveled] as a start.

This looks like it is a more correct way of doing this.

Given we have no agreed hierarchy as part of OpenRiak, will use [backend, leveled] as a start.
The leveled_log code is not aligned well with the expectations of riak kernel logger.  In particular log function calls were centralised, and so MFA metadata is irrelevant.

This change implements the log function calls as a macro, so that the should_i_log logic cna be maintained, but MFA metadata will be correctly present in the log.  It also ends the practice of adding the pid() directly to the log, instead relying on the metadata
Will be filtered by global and ?MODULE log filters.

Outstanding code coverage issue caused by detecting `false` branch when macro is substituted over multiple lines.
code coverage is an issue with the switch to macros for logging.  Not every log line will have a `false` from the log allow - and that will fail code coverage ... but only if the log covers multiple lines.

Most logs covering multiple lines, do do needlessly.  So avoid the code coverage issue by making those logs single line.
Comment thread include/leveled.hrl
Comment thread src/leveled_log.erl Outdated
Comment thread include/leveled.hrl
martinsumner and others added 3 commits November 18, 2025 15:21
Co-authored-by: Thomas Arts <thomas.arts@quviq.com>
Code uses get_loglevel/1
@martinsumner martinsumner merged commit 4583ee6 into develop-3.4 Nov 19, 2025
2 checks passed
@martinsumner martinsumner deleted the mas-d34-or.i4-domain branch November 19, 2025 13:35
martinsumner added a commit to OpenRiak/leveled that referenced this pull request Nov 19, 2025
* Switch to using domain filtering not log_type

This looks like it is a more correct way of doing this.

Given we have no agreed hierarchy as part of OpenRiak, will use [backend, leveled] as a start.

* Align log format with Erlang standards

The leveled_log code is not aligned well with the expectations of riak kernel logger.  In particular log function calls were centralised, and so MFA metadata is irrelevant.

This change implements the log function calls as a macro, so that the should_i_log logic cna be maintained, but MFA metadata will be correctly present in the log.  It also ends the practice of adding the pid() directly to the log, instead relying on the metadata

* Format via erlfmt

* ensure logger:allow/2 is called

Will be filtered by global and ?MODULE log filters.

Outstanding code coverage issue caused by detecting `false` branch when macro is substituted over multiple lines.

* Add missing space to logs with no db_id

* Coverage

code coverage is an issue with the switch to macros for logging.  Not every log line will have a `false` from the log allow - and that will fail code coverage ... but only if the log covers multiple lines.

Most logs covering multiple lines, do do needlessly.  So avoid the code coverage issue by making those logs single line.

* Update include/leveled.hrl

Co-authored-by: Thomas Arts <thomas.arts@quviq.com>

* Updates post review

* Remove unused get_log

Code uses get_loglevel/1

---------

Co-authored-by: Thomas Arts <thomas.arts@quviq.com>
martinsumner added a commit to OpenRiak/leveled that referenced this pull request Nov 19, 2025
Switch to using domain filtering not log_type (martinsumner#483)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants