0

Question1: I want to use a logger system in my application (JAVASCRIPT). What I want is that, when I call a function, so the function's name is displayed in the console...But without adding console.log() in each function. So I can see the full steps happening in my app... (if you tell me, you can use your debugger, this is not the solution I am looking for... because I just want to have it written in the console and that is all)

Question2: Such as logback in the java world, I can activate or deactivate some log per class...so I can activate / deactivate some log simply...Is there a similar way to use it in JS ?

Thanks you,

str
  • 42,689
  • 17
  • 109
  • 127
  • 2
    That's not possible. See [Adding console.log to every function automatically](http://stackoverflow.com/questions/5033836/adding-console-log-to-every-function-automatically) – GG. Apr 25 '16 at 12:08
  • 1) Thats called debugging breakpoints. 2) If you use a framework like angular you can use decorators to achieve this. In vanilla JS you need to write it yourself, there is no magic way. – Fonzy Apr 25 '16 at 12:10
  • Why it is not possible ? Or why in java I hear about dozen of logging framework (slf4, log4j, logback...) but not in JS ? Sorry but I am a java developper and not a JS one for the moment. "Logger architecture" => I mean, something well done to read good logs...not useless one, not configurable etc... (or just logging framework, you r OK) –  Apr 25 '16 at 12:11
  • 1
    why call it `logger architecture`? – gurvinder372 Apr 25 '16 at 12:12
  • There are several logging libraries for JS. But JS isn't Java. You can turn logging on and off in JS as well, but turning logging on and off in Java still relies on their being log statements in the Java code unless you're using some form of aspects--which you can also do in JS, with the expected gotchas. – Dave Newton Apr 25 '16 at 12:24
  • 1
    I do not know why they say your question is a duplicate, +1, I wait for a real answer too. One day, I did try to solve it, but I put the code in waiting state for production efficiency. You can have a look at : https://github.com/mickael-moreau/hcode/blob/master/src/tools.js, it may give some ideas... – Mickaël Apr 25 '16 at 18:47
  • When I use the Google web starter kit, and debug it, putting a breakpoint at certain line of code, finally bug the lauch of the application in the browser (blank page) even if I can finsish normally the debug... I do not know why... That si why I am also thinking of an alternative to not depend to debugging tools... And so I think that log should help... –  Apr 25 '16 at 18:55

0 Answers0