www.webdeveloper.com
Results 1 to 2 of 2

Thread: Limit maximum number of javascript log messages for a page in MVC

  1. #1
    Join Date
    Mar 2013
    Posts
    2

    Limit maximum number of javascript log messages for a page in MVC

    Hi Folks,

    I am newbie to Javascript.Our team has implement Client side Javascript logging which will log info,warning,errors and send to server..Mainly i am working on a feature where we can have a variable setting "MaxLogMessages" in Javascript logging framework.Lets say it is set to 25.

    Then max of "25" logging message can be posted for a single page so to prevent applications from flooding out the logging service.

    Need your suggestion what is the best way to implement this feature in logging framework

    Regards,
    Soni

  2. #2
    Join Date
    Jul 2008
    Location
    urbana, il
    Posts
    2,787
    one way is to monkey patch the console methods:

    Code:
    (function(){
    
      var maxMessages=25;
    
     ["log","info","warn","error"].map(function(k){
    
       var orig=console[k] || console.log ;
    
       console[k]=function(){
           if( maxMessages-- ){ return orig.apply(this, arguments); }
       };
    
      });
    
    }());

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles