Hey all, I had the block of code below working without issue.
'''
LogRestInfo is a function that logs a given message as an informational log if informational messages are enabled.
If printing to console is also enabled, it prints the message to the console.
@param msg: The message to be logged.
'''
def LogRestInfo(msg):
if showInfoMessages:
logger = system.util.logger("EpicorRest")
logger.info(msg)
if printToConsole:
print(msg)
#endif
#endif
#End LogRestInfo()
I moved the code from my EpicorFuncs library to one that was more generic for use across multiple libraries called EpicorRest. I am still getting output from that method to the Console and Script Console but not the logger anymore. All I did was move it from one library to the other trying to refactor and I can't figure out why it's being a pain in my rear.
My global variables that control the debug output at the top of the EpicorRest library this LogRestInfo method is contained in are set as follows.
# These variables control debugging output level
showInfoMessages = True
showWarnMessages = True
printToConsole = True
When I call a method such as EpicorActive in my EpicorFuncs library EpicorRest.LogRestInfo fires and everything but the logger works.

Any help and direction is appreciated. Thank you!
system.util.getLogger
does not automatically forward logs to the gateway.
Your logs are, 100% guaranteed, in the Designer's diagnostics/output console, if you're invoking your project library script from the script console.
Wouldn't the above be what pushes my logging info to the gateway? That's what it previously when it still lived in EpicorFuncs with the EpicorActive method.
Our current production instance where all this is working yet
No. system.util.getLogger()
creates a logging object in the local scope.
Note the EpicorRest
in the output console:
getLogger
is working exactly as designed. If you want your calls to automatically log to the gateway, you have to send them over yourself, e.g. using system.util.sendMessage
.
1 Like
To see more about what Paul is talking about, see the Scripting Docs about "scope"
2 Likes
The script library is just a library. It doesn't automagically rewrite your code from one execution scope to another - it's a library, a collection of scripts that can be called from multiple places.
Right I understand that and I am calling the logging function from EpicorFuncs and passing it what I want it to log.
In EpicorFuncs
def EpicorActive(res):
EpicorRest.LogRestInfo('EpicorActive (' + res + ') Called')
In EpicorRest
def LogRestInfo(msg):
if showInfoMessages:
logger = system.util.logger("EpicorRest")
logger.info(msg)
if printToConsole:
print(msg)
#endif
#endif
#End LogRestInfo()
By passing the params into EpicorRest.LogRestInfo I would then be logging it in scope of EpicorRest no?
No, "scope" is what application is executing the code, i.e. Ignition Gateway, Ignition Designer, or Vision Client.
Where does the call to EpicorActive()
originate?
3 Likes
Ahhhhh I follow now. We're talking execution scope, not code scope. I got you now. When I actually get the gateway to throw it from the tag changes I see them so back to where I was this morning.
1 Like