Giter Club home page Giter Club logo

Comments (8)

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
log isn't defined in json-template.js.  It's only defined in test-helpers.js.  
Are
you using an old version?

Original comment by [email protected] on 20 Apr 2009 at 7:01

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
I refer to you to line 23 on the current trunk.

To quote it:

// This is predefined in tests, shouldn't be defined anywhere else.  TODO: Do
// something nicer.
var log = log || function() {};

Original comment by [email protected] on 20 Apr 2009 at 9:01

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Oh, perhaps you don't consider this a definition of 'log'. It's just 
frustrating if
you want to change this and make log messages from json-template somewhere 
else, as
you'd write:

var log = function() {};

which would result in logs being turned off for *everything*.

Any log configuration system that json-template adopts to change whether you 
want to
log or not will need to modify the behavior of log, if you refer to it under 
this
global name.


Original comment by [email protected] on 20 Apr 2009 at 9:05

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
It doesn't "clobber" the log function -- it uses the one that's there if it 
*already*
exists.

I agree that customizing the log function would be useful... if you have a 
scheme
that works for you please send in a patch.


Original comment by [email protected] on 20 Apr 2009 at 9:15

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
It does write to 'log', just will write the same value back.  I'm
fine to retract the word 'clobber'. :)

Whatever it does, this approach makes it impossible to do something
*else* with that line like shut down json-template's voluminous
logging (while being interested in other logging by other js code), as the 
global name 'log' is in use throughout the json-template code. Perhaps there's 
some other way to selectively shut down logging from particular javascript 
modules?

In our copy of json-template we now renamed the uses of log to log2 so
we can shut down logging in json-template specifically when we want
to. That's hardly ideal. I'll look into a approach that does work
where json-template uses _log instead, adding an api to manipulate the logging 
situation.


Original comment by [email protected] on 21 Apr 2009 at 7:56

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024

Original comment by [email protected] on 21 Apr 2009 at 4:51

  • Changed title: configurable log function (javascript)

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
I recommend dropping the globally-visible logging hook in favor of a 
locally-scoped
one.  So, define a "log()" function on one of the json-template classes, and 
provide
examples of how the user can attach it to the global "log()" function or a
user-defined function.  By default, leave this local "log()" function defined 
as a
no-op for best performance.

Original comment by Robert.David.Williams on 14 May 2009 at 7:50

from json-template.

GoogleCodeExporter avatar GoogleCodeExporter commented on June 12, 2024
Yes, I agree with that approach.  log() shouldn't be in the global namespace.

Original comment by [email protected] on 15 May 2009 at 5:52

from json-template.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.