Haohappy的专栏--PHP5研究中心

PHP5研究中心 研究专业PHP技术,传播全球最新PHP动态 ,推广国内PHP企业应用

原创 JavaScript logger: Lumberjack收藏

As you know,it is difficult to debug a javascript app.Sometimes we use the rough alert() function (to output the error messages),but it's not  suitable for complex situations and it will stop the script. So, we need some logging frameworks,which are more powerful than alert().

Corey Johnson's Lumberjack is a Javascript logging framework which supports logging at different levels. There's no setup required, because it creates the logging div itself, so you can immediately issue calls like Logger.info("User logged in."). The console is initially hidden, and you can toggle visibility with Alt-D.

It's useful for AJAX applications,you could see what is the scirpt doing at a cert moment. Here is a screenshot :

 

And the sample source code:

function ping() {
 // Send ping, to let the server know I'm still here
 var url = base_url + 'ping.php';
 var pars = creds();

 var ajax = new Ajax.Request(url, {method: 'post', parameters: pars, onComplete: handle_ping});

 Logger.info("Sent Ping: " + pars);
}

发表于 @ 2006年12月26日 09:44:00|评论(loading...)|收藏

新一篇: 创建Google Sitemap | 旧一篇: 《PHP&MORE》 第七期发布

用户操作
[即时聊天] [发私信] [加为好友]
Haohappy
订阅我的博客
XML聚合  FeedSky
Haohappy的公告
我的Blog主要关于PHP/Java WEB开发。欢迎讨论:

MSN:

Email:


所有文章均为Haohappy原创或翻译,允许转载,但请保留出处及作者信息。


我的网站:
PHPEye开源社区
phpeye.com

我的新书:


《Programming PHP》中文版第二版,陈浩(Haohappy)、胡丹、徐景(RainX)译,电子工业出版社出版,2007年4月上市)

网上书店购买地址:
当当网(dangdang.com)
互动出版网(china-pub.com)
第二书店(dearbook.com)
华储网(huachu.com.cn)
蔚蓝书店(welan.com)

本书 配套论坛  勘误系统

常用参考手册:

文章分类
收藏
    Blogs
    Fantasy Soft(RSS)
    Freeman的Blog
    hosander的专栏
    PHPEye.com
    web2.0 focus(RSS)
    开发视界[专家专栏](RSS)
    歪脖·坑(RSS)
    存档
    Csdn Blog version 3.1a
    Copyright © Haohappy