0
Completed

Allow $logger component to specify module and submodule fields

Adrian Corston 4 years ago in UNIFYBroker Service updated by Matthew Davis (Technical Product Manager) 4 years ago 1

There is no documented way to set the third and fourth fields (which I will call 'module' and 'submodule') of each UNIFYBroker log entry when calling the $logger component.  It would be nice to be able to set them to more informative values, rather than always having them as 'UNIFYBroker' and 'PowerShellTask' respectively.

Answer

Answer
Completed

Hi Adrian,

The $logger component is designed to be a simple wrapper around the logging mechanism. For more complex log messages, use the $messageService variable. 

There's some extension methods provided for the next level of logging. You can find more information on those here:

Class NotificationEnumerableExtensions (unifysolutions.net)

Otherwise, you can use the underlying NotificationMessageService to notify listeners of a particular message. In this case, the product loggers will be listening on ILogEntryNotification: Class LogEntryNotification (unifysolutions.net)

The tricky thing with crafting one of these will be building the branding object, (for a BrandedLogEntry). Technically this would allow you to change both the 'module' and 'submodule' components.


For ease of use, i'd recommend just using the NotificationEnumerableExtensions to log - which still use the underlying product for the third field but allow you to define the fourth field.

As a side note, for some reason the $messageService variable isn't actually hooked up for the Plus components, but is hooked up for the Powershell connector and transformations.

GOOD, I'M SATISFIED
Satisfaction mark by Adrian Corston 4 years ago
Answer
Completed

Hi Adrian,

The $logger component is designed to be a simple wrapper around the logging mechanism. For more complex log messages, use the $messageService variable. 

There's some extension methods provided for the next level of logging. You can find more information on those here:

Class NotificationEnumerableExtensions (unifysolutions.net)

Otherwise, you can use the underlying NotificationMessageService to notify listeners of a particular message. In this case, the product loggers will be listening on ILogEntryNotification: Class LogEntryNotification (unifysolutions.net)

The tricky thing with crafting one of these will be building the branding object, (for a BrandedLogEntry). Technically this would allow you to change both the 'module' and 'submodule' components.


For ease of use, i'd recommend just using the NotificationEnumerableExtensions to log - which still use the underlying product for the third field but allow you to define the fourth field.

As a side note, for some reason the $messageService variable isn't actually hooked up for the Plus components, but is hooked up for the Powershell connector and transformations.