Skip to content
This repository has been archived by the owner on Sep 4, 2019. It is now read-only.

Commit

Permalink
Redirect stderr to slog2 output for debug builds
Browse files Browse the repository at this point in the history
Fixes blackberry/BB10-WebWorks-Framework#419

Reviewed By: James Keshavarzi <jkeshavarzi@rim.com>
tested By:  James Keshavarzi <jkeshavarzi@rim.com>
  • Loading branch information
Eric Pearson authored and Nukul Bhasin committed Dec 12, 2012
1 parent 36fbbb4 commit e076dce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/native-packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ function generateTabletXMLFile(session, config) {
}]
};

//Enable slog2 output if debugging
if (session.debug) {
xmlObject.env.push({
_attr : { value : 'slog2', var : 'CONSOLE_MODE' }
});
}

//If version can be attained, set env variable
if (webworksInfo && webworksInfo.version) {
xmlObject.env.push({
Expand Down
24 changes: 24 additions & 0 deletions test/unit/lib/native-packager.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,30 @@ describe("Native packager", function () {
expect(callback).toHaveBeenCalledWith(0);
});

it("makes sure slog2 logging is enabled in debug mode", function () {
var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";

//Silence the logger during unit tests
spyOn(logger, "warn").andCallFake(function () { });
spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
expect(data).toContain(tabletXMLEntry);
});

session.debug = true;
nativePkgr.exec(session, target, testData.config, callback);
});

it("makes sure slog2 logging is not enabled when not in debug mode", function () {
var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";

spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
expect(data).not.toContain(tabletXMLEntry);
});

session.debug = false;
nativePkgr.exec(session, target, testData.config, callback);
});

it("can process application name", function () {
var config = testUtils.cloneObj(testData.config);
config.name = {"default": "API Smoke Test"};
Expand Down

0 comments on commit e076dce

Please sign in to comment.