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

Add more fields to LogScenarioRule__mdt #355

Closed
jongpie opened this issue Aug 28, 2022 · 2 comments · Fixed by #357
Closed

Add more fields to LogScenarioRule__mdt #355

jongpie opened this issue Aug 28, 2022 · 2 comments · Fixed by #357
Assignees
Labels
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 tech-debt Type: Enhancement New feature or request

Comments

@jongpie
Copy link
Owner

jongpie commented Aug 28, 2022

Currently, the LogScenarioRule__mdt object provides some basic controls over Nebula Logger's behavior for a specified scenario. However, it does not have equivalent overrides for every feature currently controlled by LoggerSettings__c. Using log scenario rules, admins & devs should be able to override none/some/all feature flags that live on LoggerSettings__c. To support this, these new fields should be added to LogScenarioRule__mdt. There should also be a way to either expire a LogScenarioRule__mdt at a specified Datetime, or even better - have it only be active during a specified start & end datetime.

Existing Custom Fields

  • IsEnabled__c
  • NumberOfDaysToRetainLogs__c
  • Scenario__c
  • UserLoggingLevel__c

All Overrides for LoggerSettings__c Should Be Optional

Admins, developers (as well as ISVs) should be able to only specify the fields that they want to override on LoggerSettings__c - for a few reasons

  • Logger Settings records can more easily be updated on-the-fly: Admins & developers with the LoggerAdmin permission set can leverage the 'Logger Settings' tab/LWC to fine-tune logging features by creating/updating LoggerSettings__c records, instead of having to redeploy LogScenarioRule__mdt records.
  • Custom Metadata Types don't provide profile & user-specific levels of configuration: One of the best parts of LoggerSettings__c is that it's a custom hierarchy setting, allowing admins & developers to configure it at the organization, profile, and user levels. This makes it really easy to customize Nebula Logger differently for differents users - the LogScenarioRule__mdt custom metadata type does not have this option, so making its override fields optional gives admins & developers a way to still leverage the advantages of a custom hierarchy setting, while being able to override certain Nebula Logger feature flags.
  • New fields may be added in the future: - regression issues could be introduced in future releases if Nebula Logger assumed all fields are required on LogScenarioRule__mdt), and new fields are added, and existing records aren't updated to populate the new fields.

In order to make Boolean field optionals, the only viable option I can think of is to define the fields on LogScenarioRule__mdt as optional picklists with values of 'true' and 'false', and then parse the strings to Boolean values. It's... not my favorite, but would provide the desired functionality of "each override should be optional" & the implementation should be easy to implement/maintain.

Field Naming Conventions:

  • No Default Prefix: While the LoggerSettings__c object uses a Default prefix for several fields, such as DefaultNumberOfDaysToRetainLogs__c and DefaultSaveMethod__c, the prefix will be ommitted on the equivalent fields on LogScenarioRule__mdt to help indicate that the values on LogScenarioRule__mdt will override the defaults specified on LoggerSettings__c.
  • Modify Field Names When Needed For Clarity: Both LoggerSettings__c and LogScenarioRule__mdt have fields called IsEnabled__c (which both serve functional purposes), so LogScenarioRule__mdt.IsEnabled__c cannot be mapped to LoggerSettings__c.IsEnabled__c as an override. In this case, I'll probably use the field name LogScenarioRule__mdt.IsLoggerEnabled__c to clarify what the field controls. Other similar situations may come up later as new fields are added over time.

New Custom Fields to Prove More Control Of Rules

  • StartTime__c - optional Datetime field. When not null, the rule should only be used when IsEnabled__c == true and System.now() >= StartTime__c
  • EndTime__c - optional Datetime field. When not null, the rule should only be used when IsEnabled__c == true and System.now() <= EndTime__c

New Custom Fields to Override LoggerSettings__c Fields

Logger Engine Layer Overrides

  • IsAnonymousModeEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • IsApexSystemDebugLoggingEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • IsDataMaskingEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • IsJavaScriptConsoleLoggingEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • IsLoggerEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • IsRecordFieldStrippingEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • IsSavingEnabled__c - this will probably be an optional picklist field with values 'true' and 'false'
  • SaveMethodName__c
  • UserLoggingLevel__c (existing field)

Log Management Layer Overrides

  • LogOwner__c
  • PlatformEventStorageLocationName__c
  • NumberOfDaysToRetainLogs__c (existing field)
@jongpie jongpie added 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 Feature: Scenario-Based Logging Items related to Logger.setScenario(), LoggerScenarioRule__mdt, etc. labels Aug 28, 2022
@jongpie jongpie self-assigned this Aug 28, 2022
@jongpie jongpie added Type: Enhancement New feature or request tech-debt labels Aug 28, 2022
@jongpie
Copy link
Owner Author

jongpie commented Aug 30, 2022

As part of this work, I think I need to also add a new Apex class to manage loading/accessing LogScenarioRule__mdt records - currently, Logger and LogHandler both using the object, with some code duplication already happening 😢 A new LogScenarioRule class would be useful for centralizing stuff, including the new StartTime__c and EndTime__c fields.

@jongpie jongpie added the Layer: Log Management Items related to the custom objects & Logger Console app label Sep 1, 2022
@jongpie
Copy link
Owner Author

jongpie commented Sep 22, 2022

Closing this out, this has been released in v4.8.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 tech-debt Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant