I'd like to use clojurescript to set up a gclosure logger (goog.debug.Logger) similar to the closure demo [1]. The slightly modified javascript for this is below. How should clojurescript insulate the programmer from the mutability issues? 1) log level mutates a LogManager object 2) a logconsole object is created that will receive logger messages 3) a logger object is created
I know I can get this to work but I want to do it the best way possible and minimize cringing on the part of clojure programmers who know the language and functional programming better than I do. How about a single logging function that has a defonce for an atom which sets up 1), 2), and 3) and then uses the atom (the logger object) to reference the relevant logging method? (e.g. info) Also, it's my understanding that clojurescript doesn't support private declarations so defonce- is not possible. My reservation is a def (or defonce) shouldn't be nested in a defn. There's got to be a better way and thank you for the feedback. - Ryan --------- (defn g-log [msg] (defonce g-logger (atom (let blah blah ... (.info g-logger msg)) --------- // // javascript based on google closure demo // // Set log level goog.debug.LogManager.getRoot().setLevel(goog.debug.Logger.Level.ALL); // enable logger to receive logging messages var logconsole = new goog.debug.DivConsole(goog.dom.getElement('log')); logconsole.setCapturing(true); // create logging object var logger = goog.debug.Logger.getLogger('demo'); // now we can log stuff logger.info("This is a log message"); --------- [1] http://closure-library.googlecode.com/svn/trunk/closure/goog/demos/button.html -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en