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 a Callable implementation #371

Closed
tscottdev opened this issue Sep 22, 2022 · 9 comments · Fixed by #765
Closed

Add a Callable implementation #371

tscottdev opened this issue Sep 22, 2022 · 9 comments · Fixed by #765
Assignees
Labels
Layer: Logger Engine Items related to the core logging engine Salesforce Feature: Callable Interface Items related to dynamically using Nebula Logger via the Apex's Callable interface Salesforce Feature: OmniStudio Items related to using Nebula Logger within OmniStudio Salesforce Feature: Package Dependency Items related to ISVs/2GP packages that want to integrate with one of Nebula Logger's packages Type: Enhancement New feature or request

Comments

@tscottdev
Copy link

New Feature Summary

I've been doing some POC for an implementation that provides a Callable interface to wrap the basic logging methods so that you can make use of the logger without having to create a hard package dependency. This is particularly useful if you want to add logging to your code but don't want to force your customers to have the nebula package installed. The package can then be installed during a period of investigation and later removed. I've written a callable implementation to wrap some of the basic functionality. If this is of interest to the project, I'd be happy to contribute this.

@tscottdev tscottdev added the Type: Enhancement New feature or request label Sep 22, 2022
@jongpie
Copy link
Owner

jongpie commented Sep 22, 2022

Hi @tscottdev, thanks for the suggestion! Is there any chance you could share some of your POC code? Conceptually, I'm not a big fan of the Callable interface since it relies heavily on strings (instead of strongly-typed references), but I definitely think that there's value in the concept of having a way to log code without a hard dependency on having the full Nebula Logger package installed. I'd love to see how you've implemented it using Callable.

@tscottdev
Copy link
Author

Thanks for the reply. I've just got a few hoops to jump through with the company I work for before I can send over the POC code. As soon as I get a green light I'll send it over. :)

@tscottdev
Copy link
Author

Hi @jongpie, sorry for the delay. I've shared a repo with you that has some POC code in.

@jongpie
Copy link
Owner

jongpie commented Oct 3, 2022

Hi @tscottdev, thanks for sharing the repo with me! I won't be able to fully review it for a few days, but I'll try to review it & share my thoughts hopefully by this weekend.

@jongpie
Copy link
Owner

jongpie commented Oct 30, 2022

@tscottdev I've been tinkering with this idea some more, and unfortunately, it feels like too much extra code would be needed, and it would be difficult to support & maintain this feature (at least at this time). From a scalability perspective, it would be a big initial undertaking to make this work for all functionality in the current codebase, and it would become increasingly difficult to add support for new methods & functionality that are added to Nebula Logger in future releases. At least for now, I'm not going to move forward with adding this to the unlocked or managed packages.

But, another viable approach for optionally leveraging Nebula (when a customer does have it installed) is to create your own plugin/adapter package that depends on both your package and Nebula Logger's package. @jamessimone uses this approach in his project Apex Rollup. It avoids having a hard dependency in your primary package on Nebula Logger, while still providing a way to optionally integrate with Nebula Logger in customer orgs that have both installed. In Apex Rollup....

Based on the repo you shared, it feels like you already have a lot of the same concepts & approaches that @jamessimone has taken - the main difference is that you're using the Callable interface, and he's used an additional package (with package dependencies).

  • Both approaches require your LoggerService class to support dependency injection, so I think both approaches are more or less "tied" in terms of effort & complexity of implementations
  • With the Callable approach, both Nebula Logger & your package's implementation (LoggingServiceNebulaImpl) have to maintain hardcoded Strings, which is error prone since there would not be compile-time validations on the String values used.
  • With a plugin package/package dependencies and interface usage, there's compile-time validation, both when developing the plugin package, as well as when generating package versions for the plugin package. This would avoid a lot of issues that could happen when using the Callable interface & String values

I think using a plugin package is a better solution overall (and wouldn't require any changes within Nebula Logger), but would love to hear your thoughts on this approach.

@jongpie jongpie closed this as completed Oct 30, 2022
@jongpie jongpie added the wontfix This will not be worked on label Oct 30, 2022
@mattandneil
Copy link

mattandneil commented Mar 5, 2024

Winter '23 enables Apex to run Invocable Actions dynamically.

Here are the docs for the Invocable.Action classes and methods:
developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_Invocable_Action
This will work with the Nebula managed package because the @InvocableMethod class is global:

Example usage for FlowLogEntry

// create the action by name, then setup one invocation
Invocable.Action.createCustomAction('apex', 'Nebula', 'FlowLogEntry')
.setInvocationParameter('savelog', true)
.setInvocationParameter('flowname', 'Test')
.setInvocationParameter('message', 'log_message')
.invoke();

img

However it doesn't work with the unlocked package due to a platform bug (Case 46476985)

@jongpie
Copy link
Owner

jongpie commented Sep 11, 2024

@tscottdev almost 2 years after you opened this issue, and after reconsidering our discussion here.... I've decided that I am going to finally implement the Callable interface, for 2 reasons:

  1. A lot more people have asked for a way to loosely couple/depend on Nebula Logger (same as your original request)
  2. The Callable interface can also be used in OmniStudio - and a lot of people over the last several months have been asking for OmniStudio support (issue Add the ability to use Nebula Logger in OmniStudio #644)

I've already built a functioning implementation that can be used for ISVs/package developers - I'm now working on expanding it to also handle OmniStudio's functionality. My hope is to have a PR ready in the coming weeks (as soon as the OmniStudio part is ready).

@jongpie jongpie reopened this Sep 11, 2024
@jongpie jongpie added Layer: Logger Engine Items related to the core logging engine Salesforce Feature: OmniStudio Items related to using Nebula Logger within OmniStudio Salesforce Feature: Callable Interface Items related to dynamically using Nebula Logger via the Apex's Callable interface and removed wontfix This will not be worked on labels Sep 11, 2024
@jongpie jongpie self-assigned this Sep 11, 2024
@tscottdev
Copy link
Author

This is exciting!

@jongpie jongpie changed the title Callable implementation Add a Callable implementation Sep 13, 2024
@jongpie jongpie added the Salesforce Feature: Package Dependency Items related to ISVs/2GP packages that want to integrate with one of Nebula Logger's packages label Sep 16, 2024
@jongpie
Copy link
Owner

jongpie commented Sep 17, 2024

@tscottdev it's finally here! A new CallableLogger class is now provided in the unlocked package in release v4.14.10 🥳 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Layer: Logger Engine Items related to the core logging engine Salesforce Feature: Callable Interface Items related to dynamically using Nebula Logger via the Apex's Callable interface Salesforce Feature: OmniStudio Items related to using Nebula Logger within OmniStudio Salesforce Feature: Package Dependency Items related to ISVs/2GP packages that want to integrate with one of Nebula Logger's packages Type: Enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants