From 31e1088aa754c89dcd97f085ae4be3a40e7785d1 Mon Sep 17 00:00:00 2001 From: Jermolene Date: Thu, 15 May 2014 18:50:14 +0100 Subject: [PATCH] Clean up startup logging MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now we do boot logging to an array. We harvest it in the —verbose command. We still need to provide a way to access the log in the browser too. --- boot/boot.js | 32 +++++++++++++++++++------------- core/modules/commands/verbose.js | 2 ++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/boot/boot.js b/boot/boot.js index 4efc7f560..0b343fec3 100644 --- a/boot/boot.js +++ b/boot/boot.js @@ -45,6 +45,11 @@ if($tw.node) { /////////////////////////// Utility functions +$tw.boot.log = function(str) { + $tw.boot.logMessages = $tw.boot.logMessages || []; + $tw.boot.logMessages.push(str); +} + /* Check if an object has a property */ @@ -1089,7 +1094,7 @@ $tw.Wiki.prototype.processSafeMode = function() { // Find the overriding tiddlers this.each(function(tiddler,title) { if(self.isShadowTiddler(title)) { - console.log(title); + console.log(title); overrides.push(title); } }); @@ -1754,18 +1759,19 @@ $tw.boot.executeNextStartupTask = function() { if($tw.boot.isStartupTaskEligible(task)) { // Remove this task from the list $tw.boot.remainingStartupModules.splice(taskIndex,1); -var s = ["Executing task:",task.name]; -if(task.platforms) { - s.push("platforms:",task.platforms.join(",")); -} -if(task.after) { - s.push("after:",task.after.join(",")); -} -if(task.before) { - s.push("before:",task.before.join(",")); -} -console.log(s.join(" ")); - // Execute it + // Assemble log message + var s = ["Startup task:",task.name]; + if(task.platforms) { + s.push("platforms:",task.platforms.join(",")); + } + if(task.after) { + s.push("after:",task.after.join(",")); + } + if(task.before) { + s.push("before:",task.before.join(",")); + } + $tw.boot.log(s.join(" ")); + // Execute task if(!$tw.utils.hop(task,"synchronous") || task.synchronous) { task.startup(); if(task.name) { diff --git a/core/modules/commands/verbose.js b/core/modules/commands/verbose.js index eb2d7a405..6b0117829 100644 --- a/core/modules/commands/verbose.js +++ b/core/modules/commands/verbose.js @@ -24,6 +24,8 @@ var Command = function(params,commander) { Command.prototype.execute = function() { this.commander.verbose = true; + // Output the boot message log + this.commander.streams.output.write("Boot log:\n " + $tw.boot.logMessages.join("\n ") + "\n"); return null; // No error };