Skip to content
This repository
Browse code

Redirect stderr to slog2 output for debug builds

Fixes blackberry/BB10-WebWorks-Framework#419

Reviewed By: James Keshavarzi <jkeshavarzi@rim.com>
tested By:  James Keshavarzi <jkeshavarzi@rim.com>
  • Loading branch information...
commit e076dceadfaec154101a41bad4bb085273cce432 1 parent 36fbbb4
Eric Pearson authored December 04, 2012 Nukul Bhasin committed December 12, 2012
7  lib/native-packager.js
@@ -59,6 +59,13 @@ function generateTabletXMLFile(session, config) {
59 59
             }]
60 60
         };
61 61
 
  62
+    //Enable slog2 output if debugging
  63
+    if (session.debug) {
  64
+        xmlObject.env.push({
  65
+            _attr : { value : 'slog2', var : 'CONSOLE_MODE' }
  66
+        });
  67
+    }
  68
+
62 69
     //If version can be attained, set env variable
63 70
     if (webworksInfo && webworksInfo.version) {
64 71
         xmlObject.env.push({
24  test/unit/lib/native-packager.js
@@ -147,6 +147,30 @@ describe("Native packager", function () {
147 147
         expect(callback).toHaveBeenCalledWith(0);
148 148
     });
149 149
 
  150
+    it("makes sure slog2 logging is enabled in debug mode", function () {
  151
+        var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";
  152
+
  153
+        //Silence the logger during unit tests
  154
+        spyOn(logger, "warn").andCallFake(function () { });
  155
+        spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
  156
+            expect(data).toContain(tabletXMLEntry);
  157
+        });
  158
+
  159
+        session.debug = true;
  160
+        nativePkgr.exec(session, target, testData.config, callback);
  161
+    });
  162
+
  163
+    it("makes sure slog2 logging is not enabled when not in debug mode", function () {
  164
+            var tabletXMLEntry = "<env value=\"slog2\" var=\"CONSOLE_MODE\"></env>";
  165
+
  166
+        spyOn(pkgrUtils, "writeFile").andCallFake(function (sourceDir, outputDir, data) {
  167
+            expect(data).not.toContain(tabletXMLEntry);
  168
+        });
  169
+
  170
+        session.debug = false;
  171
+        nativePkgr.exec(session, target, testData.config, callback);
  172
+    });
  173
+
150 174
     it("can process application name", function () {
151 175
         var config = testUtils.cloneObj(testData.config);
152 176
         config.name = {"default": "API Smoke Test"};

0 notes on commit e076dce

Please sign in to comment.
Something went wrong with that request. Please try again.