UNPKG

@vroomlabs/gsdk-deploy

Version:

Google Cloud deployment script for kubernetes clusters using Global Load Balancer

57 lines (50 loc) 3.45 kB
'use strict'; /****************************************************************************** * MIT License * Copyright (c) 2017 https://github.com/vroomlabs * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Created by rogerk on 7/2/17. ******************************************************************************/ var _fs=require('fs');var fs=_interopRequireWildcard(_fs); var _logger=require('../util/logger');function _interopRequireWildcard(obj){if(obj&&obj.__esModule){return obj}else{var newObj={};if(obj!=null){for(var key in obj){if(Object.prototype.hasOwnProperty.call(obj,key))newObj[key]=obj[key]}}newObj.default=obj;return newObj}}function _asyncToGenerator(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{return Promise.resolve(value).then(function(value){step('next',value)},function(err){step('throw',err)})}}return step('next')})}} var colors=require('colors'); /** * @param {AppState} app */ module.exports=function(){var _ref=_asyncToGenerator(/*#__PURE__*/regeneratorRuntime.mark(function _callee(app){var logLines,ix,line,rec;return regeneratorRuntime.wrap(function _callee$(_context){while(1){switch(_context.prev=_context.next){case 0: logLines=fs.readFileSync(_logger.logger.logPath).toString().split('\n'); ix=Math.max(logLines.length-100,0);case 2:if(!( ix<logLines.length)){_context.next=27;break} line=logLines[ix];if( line.match(/^{.*}$/)){_context.next=6;break}return _context.abrupt('continue',24);case 6: rec=null;_context.prev=7; rec=JSON.parse(line);_context.next=15;break;case 11:_context.prev=11;_context.t0=_context['catch'](7); process.stdout.write(line+'\n');return _context.abrupt('continue',24);case 15: line=colors.gray('['+rec.timestamp.substr(11,8)+'] '+rec.level)+(': '+rec.message+'\n'); if(rec.stack)line+=colors.gray(rec.stack)+'\n'; delete rec.level; delete rec.timestamp; delete rec.message; delete rec.stack; if(Object.keys(rec).length>0){ line+=colors.gray(JSON.stringify(rec,null,2).substr(2,-4))+'\n'; } line.replace(/\n\n+/,'\n'); process.stdout.write(line);case 24:ix++;_context.next=2;break;case 27: process.exit(0);case 28:case'end':return _context.stop();}}},_callee,this,[[7,11]])}));function viewLogs(_x){return _ref.apply(this,arguments)}return viewLogs}();