Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New 'Log Scenario Rules' CMDT #237

Merged
merged 16 commits into from
Nov 10, 2021
Merged

New 'Log Scenario Rules' CMDT #237

merged 16 commits into from
Nov 10, 2021

Conversation

jongpie
Copy link
Owner

@jongpie jongpie commented Oct 26, 2021

This PR closes #235 (and further extends the 'scenario' functionality added in #218) - Added new CMDT object LoggerScenarioRule__mdt to provide a way to configure scenario-specific behavior. Each rule controls 2 aspects of a scenario:

  1. The user's logging level for a particular scenario - This overrides the logging level configured via LoggerSettings__c.
  2. The retention date for a particular scenario - This overrides the retention date configured via LoggerSettings__c.

Example rule

This example rule overrides the user's logging level for the scenario 'some scenario' - after Logger.setScenario(String) is called, the user will (temporarily) have their logging level set to FINE for the remainder of the Apex transaction. It also sets the retention date for the logs to 90 days.

image

With the above rule configured, this script will save only the second log entry (the one logged after calling Logger.setScenario(String), and the log will have a retention date of "TODAY + 90 days"

Logger.getUserSettings().LoggingLevel__c = LoggingLevel.ERROR.name();
Logger.info('this will not be saved since it does not meet the user logging level of ERROR');
Logger.setScenario('some scenario');
Logger.info('this will be saved since it meets the scenario logging level, and setScenario() has been called');
Logger.saveLog();

Other Changes

The previous release, v4.6.11, included a new dynamic dashboard. I did not take into consideration that most orgs have a limit of 10 dynamic dashboards, which has caused upgrade issues for several people already. To help with this issue, the dashboard has been removed from the core unlocked package, and is now going to be provided as an optional plugin package - any org that wants to use the dashboard (and has not hit their org limit) can install the dashboard plugin on top of Nebula Logger v4.6.12.

…override the user's logging level for a particular scenario
@jongpie jongpie added Type: Enhancement New feature or request Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Layer: Logger Engine Items related to the core logging engine labels Oct 26, 2021
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:05 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:12 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:21 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:25 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:25 Inactive
@codecov
Copy link

codecov bot commented Oct 26, 2021

Codecov Report

Merging #237 (cdd8ef0) into main (ab7dc20) will decrease coverage by 0.05%.
The diff coverage is 91.66%.

❗ Current head cdd8ef0 differs from pull request most recent head 69e9b68. Consider uploading reports for the commit 69e9b68 to get more accurate results
Impacted file tree graph

@@            Coverage Diff             @@
##             main     #237      +/-   ##
==========================================
- Coverage   95.51%   95.45%   -0.06%     
==========================================
  Files          28       28              
  Lines        2829     2858      +29     
  Branches       42       42              
==========================================
+ Hits         2702     2728      +26     
- Misses        126      129       +3     
  Partials        1        1              
Flag Coverage Δ
Apex 96.01% <91.66%> (-0.08%) ⬇️
LWC 90.07% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...ebula-logger/main/logger-engine/classes/Logger.cls 95.18% <90.90%> (-0.08%) ⬇️
...-logger/main/log-management/classes/LogHandler.cls 97.64% <92.00%> (-2.36%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ab7dc20...69e9b68. Read the comment docs.

@jongpie jongpie temporarily deployed to Test October 26, 2021 14:35 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:38 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:38 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 14:49 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 22:37 Inactive
@jongpie jongpie force-pushed the feature/log-scenario-rules branch from 7c1d423 to 0901c64 Compare October 26, 2021 22:46
@jongpie jongpie temporarily deployed to Test October 26, 2021 22:46 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 22:50 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 22:50 Inactive
@jongpie jongpie temporarily deployed to Test October 26, 2021 22:59 Inactive
@jverelst
Copy link

@jongpie I've tested this version in one of our sandboxes and indeed it works as expected, very nice, thanks!! I do have some feedback on the PR though because the package failed to install on the first try.

The package now contains a dashboard, which looks amazing, but since we already were on the limit of 10 dynamic dashboards, I had un-dynamic one of our existing dashboards. That's fine on a sandbox for testing, but will give us problems when deploying this package with the new dynamic dashboard to production.

ERROR:  Encountered errors installing the package!,Installation errors: 
1) (LogDashboards/LoggerAdmin) You reached the limit for dashboards run as the logged-in user., Details: LogDashboards/LoggerAdmin: You reached the limit for dashboards run as the logged-in user.
2) (LoggerConsoleHomePage) Component [desktopDashboards:embeddedDashboard] attribute [dashboardName]: Invalid dashboard Unique Name LoggerAdmin - no dashboards found., Details: LoggerConsoleHomePage: Component [desktopDashboards:embeddedDashboard] attribute [dashboardName]: Invalid dashboard Unique Name LoggerAdmin - no dashboards found.

I don't know if the dashboard could be an optional somehow?

@jongpie
Copy link
Owner Author

jongpie commented Oct 27, 2021

@jverelst that is some very helpful feedback, thanks for sharing! I had completely forgotten about the limit on dynamic dashboards - to avoid that issue, I'll remove the dashboards & reports from the main unlocked package as part of this PR, and I'll instead put the dashboards/reports into an optional add-on package. That way, anyone that wants to use the dashboard can easily install it in their org, but it will be completely optional.

I am also working on some additional features for the new 'Logger Retention Rules' custom metadata type - once I've made a bit more progress, I'll share another beta package link in case you'd like to test the additional changes before I finish this PR.

Thanks again for all of your feedback!

@jongpie jongpie force-pushed the feature/log-scenario-rules branch from 0b131a0 to 0c9931a Compare October 28, 2021 02:33
@jongpie jongpie temporarily deployed to Test October 28, 2021 03:28 Inactive
This plugin complements the log retention functionality in LoggerSettings__c & the LoggerScenarioRule__mdt objects
The plugin's code is based on my other repo, ApexValidationRules - I've repurposed the core code to be used for configuring log retention rules & conditions
@jongpie jongpie force-pushed the feature/log-scenario-rules branch from 03802c1 to 8b6e3e5 Compare October 28, 2021 15:30
@jongpie jongpie temporarily deployed to Test October 28, 2021 15:30 Inactive
@jongpie jongpie temporarily deployed to Test October 28, 2021 15:34 Inactive
@jongpie jongpie temporarily deployed to Test October 28, 2021 15:34 Inactive
@jongpie jongpie temporarily deployed to Test November 9, 2021 19:50 Inactive
@jongpie jongpie changed the title New "Logger Scenario Rules" New Log Scenario Rules CMDT Nov 9, 2021
@jongpie jongpie added Layer: Log Management Items related to the custom objects & Logger Console app Feature: Log Retention Items related to LogBatchPurger or LogBatchPurgeScheduler labels Nov 9, 2021
@jongpie jongpie force-pushed the feature/log-scenario-rules branch from 2dca3a2 to cdd8ef0 Compare November 9, 2021 20:02
@jongpie jongpie temporarily deployed to Test November 9, 2021 20:02 Inactive
@jongpie jongpie temporarily deployed to Test November 9, 2021 20:07 Inactive
@jongpie jongpie temporarily deployed to Test November 9, 2021 20:07 Inactive
@jongpie jongpie temporarily deployed to Test November 9, 2021 20:16 Inactive
@jongpie jongpie marked this pull request as ready for review November 9, 2021 22:08
@jongpie jongpie force-pushed the feature/log-scenario-rules branch from 45731a9 to 590c02f Compare November 10, 2021 00:00
@jongpie jongpie changed the title New Log Scenario Rules CMDT New 'Log Scenario Rules' CMDT Nov 10, 2021
@jongpie jongpie force-pushed the feature/log-scenario-rules branch from 590c02f to 69e9b68 Compare November 10, 2021 04:20
@jongpie jongpie merged commit cc8f333 into main Nov 10, 2021
@jongpie jongpie deleted the feature/log-scenario-rules branch November 10, 2021 04:31
@jongpie jongpie added the Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. label May 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature: Log Retention Items related to LogBatchPurger or LogBatchPurgeScheduler Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. Layer: Configuration Items related to the custom hierarchy setting LoggerSettings__c or any included custom metadata type Layer: Log Management Items related to the custom objects & Logger Console app Layer: Logger Engine Items related to the core logging engine Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add configurable rules for log scenario logging levels
3 participants