mothership-ec / cog

Cog
Other
2 stars 3 forks source link

Added debug log global function #482

Closed kuiche closed 8 years ago

kuiche commented 8 years ago

This will be useful for any live debugging that needs to happen. Using d() and de() is awkward as they are not silent and may cause the site users inconvenience.

Use by calling l($message). Use tail -f logs/debug.log to view the output.

thomasjthomasj commented 8 years ago

@kuiche good idea, but please can you docblock it? also I'm not sure how I feel about l() as a function name. Since it's going to be written to a file, the process is already slower than using d() and de() so I don't know if that level of convenience is necessary. Alllllso do you think we should move this to a class and then call the class from the function, like the dumper functions?

kuiche commented 8 years ago

@thomasjthomasj I was originally going to use a service, but i didn't want to rely on calling the service statically. I don't think another class for this is a good idea, its another layer of unnecessary abstraction. The function is 4 lines long.

Locally we should use d() or de(). This is not really for local debugging, although there are cases where this will be better than d(). For example you may want the request to complete after calling d(), but it may forward to other requests or otherwise hide the output. Additionally de() output sometimes gets hidden in subrequests.

I'll docblock it though.

thomasjthomasj commented 8 years ago

Can we suppress errors in this function? I tried dumping within the router to test it and I got a var_export does not handle circular references error, but if we're trying to be silent in our logging and it errors then that's not very silent