- 浏览: 2542837 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
SuperPlan(6)TaoBao Winner - UI log4javascript
10. log4javascript
10.1 Introduction
From my understanding, it is a good way to take care of the javascript Log. It should be better than the console.log.
We have this kind of log Level
log.trace(message[, message2, … ] [, exception])
log.debug(message[, message2, …] [, exception])
log.info
log.error
log.fatal
Some simple examples
log.info("Hello, sillycat");
try{
throw new Error("Faking error message.");
}catch(e){
log.error("An error occurred", e);
}
var a = "hello",
var b = 3;
log.debug(a, b);
Logging an Object will directly output an JSON format
var obj = new Object();
obj.name = "hello",
obj.age = 8;
log.info(obj);
10.2 Work it out with My Backbone framework and Chrome
In the Main.js, load the path of log4javascript and log4javascript_custom.
paths: {
jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min',
underscore: '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.1/underscore-min',
backbone: '//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min',
text: '//cdnjs.cloudflare.com/ajax/libs/require-text/2.0.5/text',
async: 'lib/require/async',
log4javascript: '//cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.3/log4javascript',
json2: '//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2',
log4javascript_custom: 'lib/log4javascript/log4javascript_custom'
}
Using and initialize the Log4j class I have created.
require([
'Router',
'Config',
'Log4j',
'json2'
], function(Router, Config, Log4j){
new Log4j().init();
var IndexPageView = Backbone.View.extend({ el: "#content", router: null, initialize: function(){ window.logger.debug("initialize the IndexPageView and whole system.", "Good Luck."); window.logger.info("Config Start=================================="); window.logger.info(JSON.stringify(new Config())); window.logger.info("Config End===================================="); this.router = new Router(); } }); new IndexPageView();
});
The most magic configuration javascript class Log4j.js will be as follow:
define([
'jquery',
'Config',
'log4javascript',
'log4javascript_custom'
], function($, Config) {
function Log4j(){
} Log4j.prototype.init = function(){ var config = new Config(); if(config.getLogEnable() == 1){ log4javascript.setEnabled(true); }else{ log4javascript.setEnabled(false); }
var logger = log4javascript.getLogger(); if(config.getLogLevel() == 'debug'){ logger.setLevel(log4javascript.Level.DEBUG); }elseif(config.getLogLevel() == 'all'){ logger.setLevel(log4javascript.Level.ALL); }elseif(config.getLogLevel() == 'info'){ logger.setLevel(log4javascript.Level.INFO); }elseif(config.getLogLevel() == 'error'){ logger.setLevel(log4javascript.Level.ERROR); }
var consoleAppender = new log4javascript.BrowserConsoleAppender(); //%d{HH:mm:ss,SSS} %l{s:l} %-5p - %m{1}%n //%d{HH:mm:ss} %-5p - %m%n var simpleLayout = new log4javascript.PatternLayout("%d{HH:mm:ss,SSS} %l{s:l} %-5p - %m %n "); consoleAppender.setLayout(simpleLayout); logger.addAppender(consoleAppender); window.logger = logger; }; return Log4j;
});
The Config.js is an idea that I want to place all the javascript configuration.
define([
'jquery'
], function($) {
function Config(){
this.logLevel = 'all'; //info, debug, all this.logEnable = 1; } Config.prototype.setLogLevel = function(logLevel){ this.logLevel = logLevel; }; Config.prototype.getLogLevel = function(){ return this.logLevel; };
Config.prototype.setLogEnable = function(logEnable){ this.logEnable = logEnalbe; };
Config.prototype.getLogEnable = function(){ return this.logEnable; }; return Config;
});
11. BackBone
come soon...
Tips:
1. Always show the line number in log4javascript
log4javascript.js:155
Solution:
Copy some implementation from log4javascript.js and create a file log4javascript_custom.js.
Change the method
define([
'log4javascript'
],function() {
log4javascript.PatternLayout.prototype.format = function(loggingEvent) {
…snip..
case"l": //Location var isChrome = navigator.userAgent.indexOf("Chrome") !== -1; if(isChrome){ //do someting else
var stack = new Error().stack;
…snip…
The detail is in the project easygooglemap/web/js/lib/log4javascript/log4javascript_custom.js.
After that, we will have the debug information like this
13:43:01,112 Router.js:20 DEBUG - init the router, and make backbone start.
References:
log4javascript
http://blog.csdn.net/realcsq/article/details/6695532
http://chenjc-it.iteye.com/blog/1574910
http://log4javascript.org/index.html
log4javascript line number
http://stackoverflow.com/questions/11308239/console-log-wrapper-that-keeps-line-numbers-and-supports-most-methods
https://gist.github.com/leoroos/3441763
BackBone
http://dailyjs.com/2012/11/29/backbone-tutorial-1/
http://www.youtube.com/watch?v=HsEw2i4wQMM
https://github.com/thomasdavis/backbonetutorials/tree/gh-pages/videos/beginner
http://backbonejs.org/#introduction
http://coenraets.org/blog/2012/02/sample-app-with-backbone-js-and-twitter-bootstrap/
http://stackoverflow.com/questions/9914952/backbone-js-complex-model-fetch
BackBone Router
https://github.com/JesterXL/Backbone-Router-Example/tree/master/code/src
10. log4javascript
10.1 Introduction
From my understanding, it is a good way to take care of the javascript Log. It should be better than the console.log.
We have this kind of log Level
log.trace(message[, message2, … ] [, exception])
log.debug(message[, message2, …] [, exception])
log.info
log.error
log.fatal
Some simple examples
log.info("Hello, sillycat");
try{
throw new Error("Faking error message.");
}catch(e){
log.error("An error occurred", e);
}
var a = "hello",
var b = 3;
log.debug(a, b);
Logging an Object will directly output an JSON format
var obj = new Object();
obj.name = "hello",
obj.age = 8;
log.info(obj);
10.2 Work it out with My Backbone framework and Chrome
In the Main.js, load the path of log4javascript and log4javascript_custom.
paths: {
jquery: '//cdnjs.cloudflare.com/ajax/libs/jquery/1.8.2/jquery.min',
underscore: '//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.1/underscore-min',
backbone: '//cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min',
text: '//cdnjs.cloudflare.com/ajax/libs/require-text/2.0.5/text',
async: 'lib/require/async',
log4javascript: '//cdnjs.cloudflare.com/ajax/libs/log4javascript/1.4.3/log4javascript',
json2: '//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2',
log4javascript_custom: 'lib/log4javascript/log4javascript_custom'
}
Using and initialize the Log4j class I have created.
require([
'Router',
'Config',
'Log4j',
'json2'
], function(Router, Config, Log4j){
new Log4j().init();
var IndexPageView = Backbone.View.extend({ el: "#content", router: null, initialize: function(){ window.logger.debug("initialize the IndexPageView and whole system.", "Good Luck."); window.logger.info("Config Start=================================="); window.logger.info(JSON.stringify(new Config())); window.logger.info("Config End===================================="); this.router = new Router(); } }); new IndexPageView();
});
The most magic configuration javascript class Log4j.js will be as follow:
define([
'jquery',
'Config',
'log4javascript',
'log4javascript_custom'
], function($, Config) {
function Log4j(){
} Log4j.prototype.init = function(){ var config = new Config(); if(config.getLogEnable() == 1){ log4javascript.setEnabled(true); }else{ log4javascript.setEnabled(false); }
var logger = log4javascript.getLogger(); if(config.getLogLevel() == 'debug'){ logger.setLevel(log4javascript.Level.DEBUG); }elseif(config.getLogLevel() == 'all'){ logger.setLevel(log4javascript.Level.ALL); }elseif(config.getLogLevel() == 'info'){ logger.setLevel(log4javascript.Level.INFO); }elseif(config.getLogLevel() == 'error'){ logger.setLevel(log4javascript.Level.ERROR); }
var consoleAppender = new log4javascript.BrowserConsoleAppender(); //%d{HH:mm:ss,SSS} %l{s:l} %-5p - %m{1}%n //%d{HH:mm:ss} %-5p - %m%n var simpleLayout = new log4javascript.PatternLayout("%d{HH:mm:ss,SSS} %l{s:l} %-5p - %m %n "); consoleAppender.setLayout(simpleLayout); logger.addAppender(consoleAppender); window.logger = logger; }; return Log4j;
});
The Config.js is an idea that I want to place all the javascript configuration.
define([
'jquery'
], function($) {
function Config(){
this.logLevel = 'all'; //info, debug, all this.logEnable = 1; } Config.prototype.setLogLevel = function(logLevel){ this.logLevel = logLevel; }; Config.prototype.getLogLevel = function(){ return this.logLevel; };
Config.prototype.setLogEnable = function(logEnable){ this.logEnable = logEnalbe; };
Config.prototype.getLogEnable = function(){ return this.logEnable; }; return Config;
});
11. BackBone
come soon...
Tips:
1. Always show the line number in log4javascript
log4javascript.js:155
Solution:
Copy some implementation from log4javascript.js and create a file log4javascript_custom.js.
Change the method
define([
'log4javascript'
],function() {
log4javascript.PatternLayout.prototype.format = function(loggingEvent) {
…snip..
case"l": //Location var isChrome = navigator.userAgent.indexOf("Chrome") !== -1; if(isChrome){ //do someting else
var stack = new Error().stack;
…snip…
The detail is in the project easygooglemap/web/js/lib/log4javascript/log4javascript_custom.js.
After that, we will have the debug information like this
13:43:01,112 Router.js:20 DEBUG - init the router, and make backbone start.
References:
log4javascript
http://blog.csdn.net/realcsq/article/details/6695532
http://chenjc-it.iteye.com/blog/1574910
http://log4javascript.org/index.html
log4javascript line number
http://stackoverflow.com/questions/11308239/console-log-wrapper-that-keeps-line-numbers-and-supports-most-methods
https://gist.github.com/leoroos/3441763
BackBone
http://dailyjs.com/2012/11/29/backbone-tutorial-1/
http://www.youtube.com/watch?v=HsEw2i4wQMM
https://github.com/thomasdavis/backbonetutorials/tree/gh-pages/videos/beginner
http://backbonejs.org/#introduction
http://coenraets.org/blog/2012/02/sample-app-with-backbone-js-and-twitter-bootstrap/
http://stackoverflow.com/questions/9914952/backbone-js-complex-model-fetch
BackBone Router
https://github.com/JesterXL/Backbone-Router-Example/tree/master/code/src
发表评论
-
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 236MongoDB 2019(3)Security and Aut ... -
Memory Leak in NodeJS
2018-12-20 06:26 728Memory Leak in NodeJS I have d ... -
Remote Desktop Client
2018-12-07 13:19 1188Remote Desktop Client There is ... -
MetaBase UI Console(2)Docker on MySQL
2018-11-29 06:58 940MetaBase UI Console(2)Docker on ... -
AWS Lambda and Serverless Timeout
2018-09-20 01:20 626AWS Lambda and Serverless Timeo ... -
2018 WebSocket(1)Introduction
2018-03-20 01:22 11052018 WebSocket(1)Introduction ... -
2018 TypeScript Update(3)Introduction Basic Grammar
2018-03-08 03:08 6022018 TypeScript Update(3)Introd ... -
2018 TypeScript Update(2)Introduction Basic Grammar - Classes and Functions
2018-03-06 05:32 5522018 TypeScript Update(2)Introd ... -
2018 TypeScript Update(1)Introduction Basic Grammar - Types and Interface
2018-03-03 01:15 6012018 TypeScript Update(1)Introd ... -
Charts and Console(6)Paging
2018-03-01 00:12 578Charts and Console(6)Paging Th ... -
Vue.JS(3)Google Login
2018-02-14 04:53 1308Vue.JS(3)Google Login I just p ... -
Vue.JS(2)Monitor Water Console - ChartJS and Axios
2018-02-14 03:17 719Vue.JS(2)Monitor Water Console ... -
Vue.JS(1)Introduction and Basic Demo
2018-02-08 06:47 607Vue.JS(1)Introduction and Basic ... -
Charts and Console(5)Validation Form
2017-10-03 05:12 805Charts and Console(5)Validation ... -
Charts and Console(4)Display and Enhancement
2017-09-20 05:39 632Charts and Console(4)Display an ... -
Charts and Console(3)Auth and Login
2017-09-13 03:45 661Charts and Console(3)Auth and L ... -
Charts and Console(2)Login and Proxy
2017-08-31 05:39 877Charts and Console(2)Login and ... -
Charts and Console(1)UI Console and RESTful Client
2017-08-29 11:02 766Charts and Console(1)UI Console ... -
Blog Project(2)Express Backend API - istanbul - mocha - bunyan
2017-06-09 00:05 474Blog Project(2)Express Backend ... -
ReactJS(5)Composition vs Inheritance
2017-06-06 05:55 1111ReactJS(5)Composition vs Inheri ...
相关推荐
作为一种广泛存在于各个领域的竞争现象,关于赢者通吃(winner-take-all)的大部分研究太复杂以至于难以很好地理解该现象。为了用简单的方式解释winner-take-all现象,提出了一个改进的winner-take-all模型,由离散...
在给定的"winner-filter.zip"压缩包文件中,包含了一个名为"维纳滤波器仿真.m"的MATLAB代码文件,这显然是一个用于仿真和分析维纳滤波器性能的程序。MATLAB是一种广泛应用于科学计算、数据分析和工程领域的编程环境...
WINNER-II场景下的信道仿真模型,可用于分析各个场景下的信道参数
SOM网络即自组织特征映射网络,采用竞争学习规则——Winner-Take-All 。网络的输出神经元之间相互竞争以求被激活,结果在每一时刻只有一个输出神经元被激活。这个被激活的神经元称为竞争获胜神经元,而其它神经元的...
WINNER II信道模型的建模与仿真 绍WINNER II信道模型所支持的场景,信道建模方法及信道参数和信道系数产生.
《AFL_Winner - MetaTrader 5脚本.zip:基于趋势反转的交易策略解析》 在金融交易领域,有效的指标工具对于投资者来说至关重要。本文将深入解析名为"AFL_Winner"的MetaTrader 5脚本,它是一款专为MT5交易平台设计的...
SCM WINNER II Channel Models, D1.1.2 V1.2, IST-4-027756 WINNER II Deliverable
为了解决上述问题,本研究提出了结合Winner-Take-All(WTA)竞争模型和改进的人工势场(Artificial Potential Field,简称APF)路径规划方法的控制策略。WTA竞争模型是一种有效的多机器人竞争问题解决方案,它模拟了...
winner2信道模型仿真了3D信道模型,里面涉及好多应用场景。可以与现实生活中的场景相匹配
FF Winner-crx插件是一款专为ESPN幻想足球爱好者设计的扩展程序,旨在帮助用户通过计算分数分布来预测比赛的可能赢家。这款插件利用了IBM Watson的先进数据分析能力,为用户提供了一个直观的方式来评估每个球员在...
6. `scenes`目录(如果有的话):Phaser中的场景是游戏的不同阶段,比如主菜单、游戏进行中、游戏结束等,每个场景都有自己的逻辑和UI。 在开发过程中,开发者会使用JavaScript编写游戏逻辑,通过Phaser提供的API...
在IT行业中,"Winner-gets-all"这个标题可能暗示了一个竞争激烈的环境,特别是在软件开发或者数据分析的场景下,其中胜者通常能获取大部分资源或市场份额。在这个特定的案例中,结合"世界高尔夫协会工作流程"的描述...
它具有旨在实现最高内存填充率和有效使用多个计算单元的简单设计,同时仍提供了抵御权衡攻击的防御能力(通过利用最新处理器的缓存和内存组织)。 Argon2具有三个变体:Argon2i,Argon2d和Argon2id。...
ZS-Young-Data-scientist-2018-Winner-Solution-rank-3:ZS年轻数据科学家挑战赛2018
冠军得主,鸡肉晚餐! :rooster: 输入列表并旋转方向盘,即可每次获得随机赢家。 :crystal_ball: 目录 特征 输入名称或对象列表。 编辑并删除您的列表。...机会:JavaScript的随机对象生成器 Netlify :前端托管服务
默认情况下,winner-mode 包含在 emacs 中,因为版本 20 但它没有启用。 这是一个制作支持微功能的包的实验。 我有一段时间的想法,我终于要测试了。 安装 这个包裹是果酱。 从果酱安装它 package-install winner-...
克隆或分叉此存储库: git clone https://github.com/jamigibbs/and-the-winner-is 安装依赖项: npm install 下载并安装桌面在Neo4j桌面上,使用用户neo4j和密码1234创建一个新的图形数据库。 注意:在生产
ToneWinner天逸设备说明书
这将安装依赖项,编译构建的 JavaScript,然后启动服务器以查看的运行示例。 您对现有jsx文件所做的任何更改都会触发webpack自动重建。 刷新浏览器即可查看更改,无需重新启动npm start 。 React工具 我建议在 ...
在电子商务领域,组合拍卖(Combinatorial Auction)是一种复杂而有趣的拍卖形式,它允许投标人提交对多个物品的联合出价,而非仅仅对单个物品出价。这种拍卖机制旨在优化资源配置,提高拍卖效率,同时也增加了投标...