From 6cd646854c45697c2487a9522cf90244184e560e Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 16 Jan 2013 04:00:16 -0500 Subject: [PATCH] refactored --- cloudcmd.js | 10 +++++----- lib/client.js | 6 +++--- lib/server.js | 46 +++++++++++++++++++++++----------------------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/cloudcmd.js b/cloudcmd.js index e8ebc547..40f2ebd9 100644 --- a/cloudcmd.js +++ b/cloudcmd.js @@ -142,14 +142,14 @@ var lServerDir = path.dirname(process.argv[1]) + '/'; if( DIR !== lServerDir ){ - console.log('current dir: ' + DIR); + Util.log('current dir: ' + DIR); process.chdir(lServerDir); } - console.log('server dir: ' + lServerDir + '\n' + + Util.log('server dir: ' + lServerDir + '\n' + 'reading configuretion file config.json...'); if(Config){ - console.log('config.json readed'); + Util.log('config.json readed'); /* if command line parameter testing resolved * setting config to testing, so server @@ -159,13 +159,13 @@ var lArg = process.argv; lArg = lArg[lArg.length - 1]; if ( lArg === 'test' || lArg === 'test\r') { - console.log(process.argv); + Util.log(process.argv); Config.server = Config.logs = false; } if (Config.logs) { - console.log('log param setted up in config.json\n' + + Util.log('log param setted up in config.json\n' + 'from now all logs will be writed to log.txt'); writeLogsToFile(); } diff --git a/lib/client.js b/lib/client.js index b6534d82..a36065c3 100644 --- a/lib/client.js +++ b/lib/client.js @@ -313,7 +313,7 @@ function baseInit(pCallBack){ var lFunc = applicationCache.onupdateready; applicationCache.onupdateready = function(){ - console.log('app cacheed'); + Util.log('app cacheed'); location.reload(); Util.exec(lFunc); @@ -561,7 +561,7 @@ CloudCmd._ajaxLoad = function(pFullPath, pOptions){ pFullPath = '/'; } - console.log ('reading dir: "' + lPath + '";'); + Util.log ('reading dir: "' + lPath + '";'); if(!pOptions.nohistory) @@ -625,7 +625,7 @@ CloudCmd._ajaxLoad = function(pFullPath, pOptions){ * сохранения в localStorage */ var lJSON_s = JSON.stringify(data); - console.log(lJSON_s.length); + Util.log(lJSON_s.length); /* если размер данных не очень бошьой * сохраняем их в кэше diff --git a/lib/server.js b/lib/server.js index 0579b309..8406e2e4 100644 --- a/lib/server.js +++ b/lib/server.js @@ -76,7 +76,7 @@ /* node v0.4 not contains zlib */ Zlib = main.zlib; /* модуль для сжатия данных gzip-ом*/ if(!Zlib) - console.log('to use gzip-commpression' + + Util.log('to use gzip-commpression' + 'you should use newer node version\n'); /* добавляем модуль с функциями */ @@ -128,7 +128,7 @@ this.Config = pConfig; else - console.log('warning: configuretion file config.json not found...\n' + + Util.log('warning: configuretion file config.json not found...\n' + 'using default values...\n' + JSON.stringify(this.Config)); @@ -163,16 +163,16 @@ if(lConfig.socket && CloudServer.Socket){ lListen = CloudServer.Socket.listen(this.Server); } - console.log('* Sockets ' + (lListen ? 'running' : 'disabled') + '\n' + + Util.log('* Sockets ' + (lListen ? 'running' : 'disabled') + '\n' + '* Server running at http://' + this.IP + ':' + this.Port); }, this)); if(lError){ - console.log('Cloud Commander server could not started'); - console.log(lError); + Util.log('Cloud Commander server could not started'); + Util.log(lError); } }else - console.log('Cloud Commander testing mode'); + Util.log('Cloud Commander testing mode'); }; @@ -202,11 +202,11 @@ */ lQuery = lParsedUrl.query; if(lQuery) - console.log('query = ' + lQuery); + Util.log('query = ' + lQuery); /* added supporting of Russian language in directory names */ lPath = Querystring.unescape(lPath); - console.log('pathname: ' + lPath); + Util.log('pathname: ' + lPath); /* получаем поддерживаемые браузером кодировки*/ var lAcceptEncoding = pReq.headers['accept-encoding']; @@ -224,7 +224,7 @@ var lNoJS_s = CloudFunc.NOJS, lFS_s = CloudFunc.FS; - console.log("request for " + lPath + " received..."); + Util.log("request for " + lPath + " received..."); if( lConfig.rest ){ var lRestWas = Util.exec(CloudServer.rest, { @@ -262,7 +262,7 @@ /* добавляем текующий каталог к пути */ var lName = '.' + lPath; - console.log('reading ' + lName); + Util.log('reading ' + lName); /* watching is file changed */ if(lConfig.appcache) @@ -281,7 +281,7 @@ var lFileData = CloudServer.Cache.get( CloudServer.Gzip?(lName+'_gzip') : lName); - console.log(Path.basename(lName)); + Util.log(Path.basename(lName)); var lMinify = CloudServer.Minify; @@ -295,7 +295,7 @@ * CloudServer cache */ if(!lFileData && lMinify._allowed){ - console.log('trying to read data from Minify.Cache'); + Util.log('trying to read data from Minify.Cache'); lFromCache_o.cache = false; @@ -312,7 +312,7 @@ */ lFromCache_o.minify = !lFromCache_o.cache; - console.log(lName + ' readed from cache'); + Util.log(lName + ' readed from cache'); /* передаём данные с кэша, * если gzip включен - сжатые @@ -402,7 +402,7 @@ CloudServer.Queries[DirPath] = lQuery; Util.log(lQuery); - console.log(DirPath); + Util.log(DirPath); /* читаем основные данные о файле */ @@ -445,7 +445,7 @@ /* отдаём файл */ else if(pStat.isFile()){ Fs.readFile(DirPath, CloudServer.getReadFileFunc(DirPath)); - console.log('reading file: '+ DirPath); + Util.log('reading file: '+ DirPath); } } }; @@ -459,7 +459,7 @@ CloudServer._readDir = function (pError, pFiles) { if(pError){ - console.log(pError); + Util.log(pError); CloudServer.Statuses[DirPath] = 404; CloudServer.sendResponse('OK',pError.toString(), @@ -601,7 +601,7 @@ CloudServer.indexReaded = function(pList){ return function(pError, pIndex){ if(pError){ - return console.log(pError); + return Util.log(pError); } var lSrv = CloudServer, @@ -659,7 +659,7 @@ var lReadFile = function(pError, pData, pFromCache_o){ var lSrv = CloudServer; if (!pError){ - console.log('file ' + pName + ' readed'); + Util.log('file ' + pName + ' readed'); /* берём из кэша данные файла * если их нет в кэше - @@ -687,9 +687,9 @@ lSrv.sendResponse(lHeader, pData, pName); } else{ - console.log(pError.path); + Util.log(pError.path); if(pError.path !== 'passwd.json'){ - console.log(pError); + Util.log(pError); /* sending page not found */ lSrv.Statuses[pName] = 404; @@ -717,13 +717,13 @@ */ if(CloudServer.Cache.isAllowed){ /* устанавливаем кєш */ - console.log(pName+' gziped'); + Util.log(pName+' gziped'); CloudServer.Cache.set(pName+'_gzip', pResult); } CloudServer.sendResponse(pHeader, pResult, pName); } else{ - console.log(error); + Util.log(error); CloudServer.sendResponse(pHeader, error); } }; @@ -746,7 +746,7 @@ lResponse.writeHead(lStatus, pHead); lResponse.end(pData); - console.log(pName + ' sended'); + Util.log(pName + ' sended'); } };