You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, This might not be the correct place to ask this question but I am not sure where to go.
I am trying to use the Logger package to log a few functions in a package I'm writing. The functions in question live inside different namespaces. My problem comes when I try to call the logger inside of those namespaces, there is no way I could find to create an instance of a Logger and actually use them after I build my package and load it in a different workspace.
Any help would be appreciated, if this is not the correct place to ask for questions please close the issue and point to a better location.
The text was updated successfully, but these errors were encountered:
Let me repeat the question: you have, say, a namespace Foo and inside Foo, say, namespaces A and B, and you want to be able to use an instance of Logger from Foo, A and B, correct?
Let's assume you are creating an instance of Logger named MyLogger in your constructor. Then you can call MyLogger.Log from inside Foo, so that's just fine.
From inside A and B (and also other namespaces even more deeply nested) you have several options:
You can use the ##.MyLoogger syntax.
This gets cumbersome if the nesting levels go deeper: ##.##.MyLogger does not look nice, does it?!
You can inject references into A and B. From inside Foo:
(A B).MyLogger←Mylogger
Now you can call MyLogger.Log from all namespaces.
This solution is preferable when there are plenty of places the package is called from.
In this example, that does not make too much sense, but you get the picture: with a package offering many different calls, this is a pretty neat technique.
Use ⎕PATH - I strongly advise against this.
The more complex an application gets the more difficult it gets to keep track of what is actually happening, yet complexity is why a solution was needed in the first place.
In case I misunderstood your question please clarify.
If you are happy with my answer please close the issue, otherwise let me know.
Hello, This might not be the correct place to ask this question but I am not sure where to go.
I am trying to use the Logger package to log a few functions in a package I'm writing. The functions in question live inside different namespaces. My problem comes when I try to call the logger inside of those namespaces, there is no way I could find to create an instance of a Logger and actually use them after I build my package and load it in a different workspace.
Any help would be appreciated, if this is not the correct place to ask for questions please close the issue and point to a better location.
The text was updated successfully, but these errors were encountered: