Adding _logChanges()
#2970
DandyLyons
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Related: #2969
In the near future, I would like to implement a _logChanges() function. Using Apple's Logger has a number of benefits over print including:
See OSLogType.
The Logger object has slightly more upfront work than using print. You cannot simply log. You must first create a Logger, and then you call log on that Logger. Loggers are easy to create, and a Logger can even be labelled with a subsystem and category. With TCA we could potentially add this subsystem and category automatically. For example, we could simply use the name of the Reducer as the subsystem, and the category could be derived from the action. For example, a .viewAction could create a category of View. It's conceivably possible that _logChanges() could handle all of this for us!
Potential Challenges
Unlike
print()
, the Logger does not accept aString
value to log messages. Instead it accepts anOSLogMessage
. In practice, this is used almost exactly like a String, however there are certain things you can't do. For example, this doesn't work:AFAICT, Apple designed it this way to prevent developers from using Logger to leak user data. Usage is simple though. You just have to define your log messages statically, inline. (String interpolation is still allowed.)
Beta Was this translation helpful? Give feedback.
All reactions