-
Notifications
You must be signed in to change notification settings - Fork 71
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
Event Logger #78
Comments
One random idea i just had: maybe we can create a protocol for all actions to support debugging to console. For example, we introduce an additional attribute called
Note that this All actions are free to implement this additional attribute
The benefit of this approach would be:
Expanding on this idea, potentially we could allow the In fact I have written an extension for sending analytics to segment.io, which is a great example to demonstrate why this One constraint with Jasonette is there is only a single action call chain and currently it doesn't support multithreaded actions. This is by design for now because handling multithreading is not a trivial matter both for implementation and for usage (from user's point of view), so it's good to keep it simple for now. The way
While it works for this case, this approach cannot cover all analytics use cases. For example you may want to send events to segment.io BEFORE sending the network.request, or maybe even during the action. In this case we could utilize the
Actually, i'm now even wondering this That said, I don't want this to be an architecture astronaut thread, and I'm not saying we should implement all these features from the beginning. It's just a dump of an idea i just had, hope to hear what you think. |
@gliechtenstein 💯 !!!
Again I'm really keen to implement this, so maybe break up the debug vs analytics into separate issues to get them implemented more quickly? |
Some ideas 👍 I think having a logger property on the head can be used for configuration a logger server. And then every logger call will send the logs using this info. {
"$jason": {
"head" : {
"title" : "Logger Test",
"loggers" : {
"localhost" : {
"url" : "http://logger.example.com",
"level" : "trace|debug|info|warning|error|fatal",
"default" : "true",
"method" : "post",
"header": {
"X-Auth-Token": "abc1234",
}
}
}
}
}
} As you can see it's similar to level defines what kind of messages will be sent to the logger server. If set to debug will send all debug and superior priority messages. If set to info will ignore debug messages and sent info or superior priority messages and so on. More info default UsageUsing the debug syntax, but with the logger as type. Uses the default logger unless otherwise specified with the
Logging internal JasonetteFor improving debug, Jasonette needs to log things as they go. For this to work then you have to specify the 'jasonette' logger. It will log every event that triggers when parsing jasonette files by the app on runtime.
What do you think? |
Re @clsource : First I want to make sure I'm understanding correctly. Are we talking about a custom Jasonette log server that's able to log the result? Or is this about any analytics service (such as google analytics, segment, mixpanel, etc.)? I think it would be great to have a node.js server that can be set up either locally or remotely to do custom logging for Jasonette. As for the JSON syntax proposal, I hope that we can come up with a way to do this without a new addition to the ever-growing schema we already have. Actually I have a feeling this and the custom events issues are somewhat related and maybe there's a way to implement this idea using the "register and call later" pattern somehow? Could you take a look at the custom events issue and let me know if that is something that may make sense for us to use to implement your idea? Overall I'm a fan of the idea, but it would be desirable if we can come up with an implementation that doesn't introduce new concepts if possible. Re @maks :
I agree this would be nice. But let's break this down to another issue and decide on an actual implementation AFTER the basic feature (attaching debug on actions) is rolled out and have been in use for a bit. I find that it's best to design APIs based on actual usage or otherwise we end up with a syntax that's not really optimal for actual use cases. A lot of times I found that if I don't do it this way i ended up inventing new syntax that's totally unnecessary and could have been handled with existing schema in some clever way.
This one is much more complex than simply logging to console because there are many different analytic services out there each with their own API, which is why I think analytics are best implemented as extensions. But again, this may not be true and we may be able to come up with a uniform interface to handling this, but this should only be based on actual usage.
how would a $console action work as you're envisioning it? There is an extension I worked on called Overall, I think we should really break this down to pieces and implement incrementally. Otherwise we can get into analysis paralysis mode easily. Here's a suggestion:
I think step 1 is pretty straight-forward as @jashot7 is already using this in his fork and it's working fine. All we need to do is just come to a conclusion on whether we will adopt the approach I suggested (include debug option inside an action and control it via JSON instead of hardcoding) Let me know what you think, and we can get this going! |
@gliechtenstein sure I will look into custom events and think a way to create a logger for jasonette events using existing sintax 👍 |
I just made a PR Jasonette/JASONETTE-iOS#258 based on @jashot7 's original code. Made a little change to log not just the body but also header. It's just a basic logging feature that turns on and off based on Any suggestions? Otherwise i think we can implement the same thing for |
Awesome, @gliechtenstein. In order for this to replace what I'm currently doing for logging, it has to be something that I can turn on and off app-wide quickly and easily. Implementing this for JasonTimerAction and other actions would be super as well. In particular, logging the requests made with Require would be really useful and I'm adding that next to our logger. |
How about this for global debug mode on $debug.on and $debug.off
Then activate the global debug in the |
@gliechtenstein and I had a brief chat about this today.
There should be a Jasonette logger that fires events for common actions, such as the ones below:
I currently have an implementation of a very basic/simple version of this that simply logs these events to the xCode console using NSLog, but ideally a great implementation for Jasonette would include logging everything over Wifi without the need for xCode (node server) and ties into common analytics engines (Google Analytics, etc.).
Also, this implementation will need to be cross-platform and my simple example I provide is iOS only at the moment.
Example Log Calls:
Example JasonetteLogger:
The text was updated successfully, but these errors were encountered: