PHP Classes

File: ajaxLogger.min.js

Recommend this page to a friend!
  Classes of Asbjorn Grandt   AJAX Logger   ajaxLogger.min.js   Download  
File: ajaxLogger.min.js
Role: Auxiliary data
Content type: text/plain
Description: client side javascript, minified
Class: AJAX Logger
Handle log requests sent by AJAX applications
Author: By
Last change: Added header comment
Date: 12 years ago
Size: 1,616 bytes
 

Contents

Class file image Download
/** * ajaxLogger. * v1.0 * Client side Javascript to send log statements to the server side logger. * License: LGPL * Author: Asbjorn Grandt */ var LoggerLevel={OFF:2147483647,FATAL:5E4,ERROR:4E4,WARN:3E4,INFO:2E4,DEBUG:1E4,TRACE:5E3,ALL:-2147483647},LoggerSettings={path:"ajaxLogger.php"},Logger={name:"ajaxLogger",loglevel:LoggerLevel.OFF,isInitialized:false,isIdle:true,queue:[],getLogger:function(a){$.ajax({type:"POST",url:LoggerSettings.path,data:{action:"init",name:a},dataType:"json",success:function(b){if(b.result=="ok")Logger.setLevel(b.level),Logger.setName(a),Logger.isInitialized=true,Logger.spoolQueue()}});return Logger},log:function(a, b){if(Logger.isInitialized&&Logger.isIdle){if(Logger.isEnabledFor(a))Logger.isIdle=false,$.ajax({type:"POST",url:LoggerSettings.path,data:{action:"log",name:Logger.getName(),level:a,msg:b},dataType:"json",success:function(){Logger.isIdle=true;Logger.spoolQueue()}})}else Logger.queue[Logger.queue.length]={level:a,message:b}},spoolQueue:function(){if(Logger.queue.length>0){var a=Logger.queue.shift();Logger.log(a.level,a.message)}},setName:function(a){Logger.name=a},getName:function(){return Logger.name}, setLevel:function(a){Logger.loglevel=a},getLevel:function(){return Logger.loglevel},fatal:function(a){Logger.log(LoggerLevel.FATAL,a)},error:function(a){Logger.log(LoggerLevel.ERROR,a)},warn:function(a){Logger.log(LoggerLevel.WARN,a)},info:function(a){Logger.log(LoggerLevel.INFO,a)},debug:function(a){Logger.log(LoggerLevel.DEBUG,a)},trace:function(a){Logger.log(LoggerLevel.TRACE,a)},isEnabledFor:function(a){return a>=Logger.getLevel()}};