Return-Path: X-Original-To: apmail-cordova-dev-archive@www.apache.org Delivered-To: apmail-cordova-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 28751189FE for ; Thu, 6 Aug 2015 10:03:07 +0000 (UTC) Received: (qmail 73841 invoked by uid 500); 6 Aug 2015 10:03:06 -0000 Delivered-To: apmail-cordova-dev-archive@cordova.apache.org Received: (qmail 73797 invoked by uid 500); 6 Aug 2015 10:03:06 -0000 Mailing-List: contact dev-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list dev@cordova.apache.org Received: (qmail 73784 invoked by uid 99); 6 Aug 2015 10:03:06 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Aug 2015 10:03:06 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 6BCF9E683D; Thu, 6 Aug 2015 10:03:06 +0000 (UTC) From: alsorokin To: dev@cordova.apache.org Reply-To: dev@cordova.apache.org References: In-Reply-To: Subject: [GitHub] cordova-windows pull request: CB-8936 Added logging functionality Content-Type: text/plain Message-Id: <20150806100306.6BCF9E683D@git1-us-west.apache.org> Date: Thu, 6 Aug 2015 10:03:06 +0000 (UTC) Github user alsorokin commented on a diff in the pull request: https://github.com/apache/cordova-windows/pull/107#discussion_r36398856 --- Diff: template/cordova/lib/log.js --- @@ -0,0 +1,226 @@ +/* + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +*/ + +var path = require('path'), + et = require('elementtree'), + Q = require('q'), + cp = require('child_process'), + shelljs = require('shelljs'); + +var appTracingLogInitialState = null, + adminLogInitialState = null; + +/* + * Gets windows AppHost/ApplicationTracing and AppHost/Admin logs + * and prints them to console + */ +module.exports.run = function() { + getLogState('Microsoft-Windows-AppHost/ApplicationTracing').then(function (state) { + appTracingLogInitialState = state; + return getLogState('Microsoft-Windows-AppHost/Admin'); + }).then(function(state) { + adminLogInitialState = state; + return enableLogging('Microsoft-Windows-AppHost/Admin'); + }).then(function () { + return enableLogging('Microsoft-Windows-AppHost/ApplicationTracing'); + }).then(function () { + console.log('Logging enabled, now printing logs. To stop, please press Ctrl+C once.'); + startLogging('Microsoft-Windows-AppHost/Admin'); + startLogging('Microsoft-Windows-AppHost/ApplicationTracing'); + }).catch(function (error) { + console.error(error); + }); + + // Disable logs before exiting + process.on('exit', function () { + if ((appTracingLogInitialState !== null) && !appTracingLogInitialState) { + disableLogging('Microsoft-Windows-AppHost/ApplicationTracing'); + } + if ((adminLogInitialState !== null) && !adminLogInitialState) { + disableLogging('Microsoft-Windows-AppHost/Admin'); + } + }); + + // Catch Ctrl+C event and exit gracefully + process.on('SIGINT', function () { + process.exit(2); + }); + + // Catch uncaught exceptions, print trace, then exit gracefully + process.on('uncaughtException', function(e) { + console.log(e.stack); + process.exit(99); + }); +}; + +function startLogging(channel) { + var startTime = new Date().toISOString(); + setInterval(function() { + var command = 'wevtutil qe ' + channel + ' /q:"*[System [(TimeCreated [@SystemTime>\'' + startTime + '\'])]]" /e:root'; --- End diff -- @robpaveza Actually, I just modified the script so that it wouldn't fail if it hasn't administrator privileges, but only warn about that and try to show the logs that are already enabled. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org For additional commands, e-mail: dev-help@cordova.apache.org