unic / estatico

[DEPRECATED] Estático – Static site generator for frontend unicorns
Other
121 stars 18 forks source link

[Feature] Log: create a console.log wrapper with context #3

Closed d-simon closed 8 years ago

d-simon commented 9 years ago

We usually use a log wrapper such as bows to wrap and namespace our logs. I implemented a simple console.log wrapper which keeps the linenumber and prepends all log messages with the current module name.

This allows two things:

d-simon commented 9 years ago

(Tests are failing, I'm looking into it)

d-simon commented 9 years ago

Funny. It seems Phantom <2.0 does not have bind. https://github.com/ariya/phantomjs/issues/10522

d-simon commented 9 years ago

I added a bind method as a fill in for the missing bind. Test are running successfully now. Question is whether this (the whole log thing) belongs in the head. What do you think? @backflip

backflip commented 8 years ago

STOP BOTHERING US WITH PULL REQUESTS!

Having said that:

  1. We love it.
  2. We want it.
  3. There are some implementation ideas:
    • Add a new file dev.js which is included in layout.hbs depending on the environment. This way, we can easily remove this for production.
    • Include bows there by default.
    • Load the bind polyfill specifically for PhantomJS since we need this in other situations, too. E.g. by injecting a phantomjs-polyfill.js here: https://github.com/unic/estatico/blob/develop/gulp/js/qunit.js#L55

How should we continue on this? We could create a feature branch where you could point this pull request to and we would take over from there. Or we go grab a coffee and have a look at it together.

d-simon commented 8 years ago

I'm a bit short on time currently and I hate coffee. Sounds good?

Actually, I have something just like that in use already. Over here:

When I think about it, it might also be convenient to have a way to load the dev.js in production for debugging purposes. This could be a simple js hook that checks for a query parameter (such as ?debug=true). What do you think? Edit: Of course the script file would have to be loaded synchronously. (Is that even possible?)

backflip commented 8 years ago

But coffee is good for you!

d-simon commented 8 years ago

evilcoffee

backflip commented 8 years ago

Before I forget: Muchísimas gracias, we introduced this in v4 and made you immortal by mentioning your name in the changelog. Let's have that coffee anyway.