Skip to content

Commit df385d9

Browse files
committed
logging
1 parent ca525c5 commit df385d9

File tree

10 files changed

+44
-36
lines changed

10 files changed

+44
-36
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FireSight
22
node-v*
33
node
44
npm
5+
logs
56
*.log
67
*.class
78
*.wiki

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
firenodejs
22
----------
33

4+
0.18.1
5+
------
6+
* NEW: Save firenodejs log files in logs
7+
48
0.18.0
59
------
610
* NEW: DeltaMesh dual z-plane scans (required for z-calibration)

js/firestep/driver.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ try {
7979
that.firestep_proc.stdout.on('data', function(buffer) {
8080
var data = buffer.toString();
8181
data = data.substr(0, data.length - 1); // chop LF to match serialport
82-
//console.log("TTY\t: firestep stdout:" + data);
82+
//console.log("TTY \t: firestep stdout:" + data);
8383
that.onSerialData(data);
8484
});
8585
that.firestep_proc.stderr.on('data', function(data) {
@@ -92,11 +92,11 @@ try {
9292
Logger.start("FireStepDriver(" + that.model.rest.serialPath + ") " + cmd);
9393
var child1 = child_process.exec(cmd, function(error, stdout, stdin) {
9494
if (error instanceof Error) {
95-
console.log("TTY\t: FireStepDriver(" + that.model.rest.serialPath + ") attempt #1:" + error);
95+
console.log("TTY \t: FireStepDriver(" + that.model.rest.serialPath + ") attempt #1:" + error);
9696
var child2 = child_process.exec(cmd, function(error, stdout, stdin) {
9797
if (error instanceof Error) {
9898
reset_serialDriver(that);
99-
console.log("TTY\t: FireStepDriver(" + that.model.rest.serialPath + ") RETRY #1:" + error);
99+
console.log("TTY \t: FireStepDriver(" + that.model.rest.serialPath + ") RETRY #1:" + error);
100100
} else {
101101
onOpenSuccess(that, stdout, 2);
102102
}
@@ -106,7 +106,7 @@ try {
106106
}
107107
});
108108
} catch (e) {
109-
console.log("TTY\t: FireStepDriver(" + that.model.rest.serialPath + ") UNAVAILABLE:" + e);
109+
console.log("TTY \t: FireStepDriver(" + that.model.rest.serialPath + ") UNAVAILABLE:" + e);
110110
reset_serialDriver(that);
111111
}
112112
}
@@ -181,7 +181,7 @@ try {
181181
FireStepDriver.prototype.write = function(cmd) {
182182
var that = this;
183183
that.model.writes++;
184-
console.log("TTY\t: WRITE(" + that.model.writes + ") " + cmd + "\\n");
184+
console.log("TTY \t: WRITE(" + that.model.writes + ") " + cmd + "\\n");
185185
try {
186186
if (that.serial) {
187187
that.serial.write(cmd);
@@ -197,7 +197,7 @@ try {
197197
that.firestep_proc.stdin.write("\n");
198198
} else {
199199
// FireStep spawn failed
200-
console.log("TTY\t: firestep response TIMEOUT:" + that.msLaunchTimeout + "ms");
200+
console.log("TTY \t: firestep response TIMEOUT:" + that.msLaunchTimeout + "ms");
201201
reset_serialDriver(that);
202202
}
203203
}, that.msLaunchTimeout);
@@ -206,19 +206,19 @@ try {
206206
throw new Error("no serial driver");
207207
}
208208
} catch (e) {
209-
console.log("TTY\t: FireStepDriver(" + that.model.rest.serialPath + ") UNAVAILABLE:" + e);
209+
console.log("TTY \t: FireStepDriver(" + that.model.rest.serialPath + ") UNAVAILABLE:" + e);
210210
reset_serialDriver(that);
211211
}
212212
}
213213
FireStepDriver.prototype.processQueue = function() {
214214
var that = this;
215215
if (that.serialQueue.length <= 0) {
216-
//console.log("TTY\t: FireStepDriver.processQueue(empty) ");
216+
//console.log("TTY \t: FireStepDriver.processQueue(empty) ");
217217
} else if (!that.model.available) {
218-
console.log("TTY\t: FireStepDriver.processQueue(unavailable) ", that.serialQueue.length,
218+
console.log("TTY \t: FireStepDriver.processQueue(unavailable) ", that.serialQueue.length,
219219
" items");
220220
} else if (that.serialInProgress) {
221-
//console.log("TTY\t: FireStepDriver.processQueue(busy) ", that.serialQueue.length, " items");
221+
//console.log("TTY \t: FireStepDriver.processQueue(busy) ", that.serialQueue.length, " items");
222222
} else {
223223
that.serialInProgress = true;
224224
var jcmd = that.serialQueue.shift();
@@ -231,7 +231,7 @@ try {
231231
FireStepDriver.prototype.onSerialData = function(data) {
232232
var that = this;
233233
that.model.reads++;
234-
console.log("TTY\t: READ(" + that.model.reads + ") " + data + "\\n");
234+
console.log("TTY \t: READ(" + that.model.reads + ") " + data + "\\n");
235235
if (typeof data !== 'string') {
236236
throw new Error("expected Javascript string for serial data return");
237237
}
@@ -244,8 +244,8 @@ try {
244244
that.handlers.response(response);
245245
request.resp = response;
246246
if (response.s < 0) {
247-
console.log("TTY\t: FireStep COMMAND FAILED:" + data);
248-
console.log("TTY\t: FireStepDriver() COMMAND QUEUE CLEARED " + that.serialQueue.length + " ITEMS");
247+
console.log("TTY \t: FireStep COMMAND FAILED:" + data);
248+
console.log("TTY \t: FireStepDriver() COMMAND QUEUE CLEARED " + that.serialQueue.length + " ITEMS");
249249
that.serialQueue = [];
250250
}
251251
}
@@ -255,7 +255,7 @@ try {
255255
try {
256256
request.onDone && request.onDone(request.resp);
257257
} catch (e) {
258-
console.log("TTY\t: ERROR(response handler failed):" + data, e);
258+
console.log("TTY \t: ERROR(response handler failed):" + data, e);
259259
}
260260
that.processQueue();
261261
if (that.serialQueue.length == 0) {

js/firestep/mock-driver.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function mockAsync(callback) {
1717
var mockSerial = function(that, cmd) { // CANNOT BLOCK!!!
1818
that.model.writes = that.model.writes ? that.model.writes + 1 : 1;
1919
var serialData = JSON.stringify(cmd);
20-
console.log("TTY\t: WRITE(" + that.model.writes + ") " + serialData + "\\n");
20+
console.log("TTY \t: WRITE(" + that.model.writes + ") " + serialData + "\\n");
2121

2222
// SEND SERIAL DATA HERE
2323

@@ -138,10 +138,10 @@ function mockAsync(callback) {
138138
};
139139
that.handlers = {
140140
idle: function() {
141-
// console.log("TTY\t: idle");
141+
// console.log("TTY \t: idle");
142142
},
143143
response: function(response) {
144-
// console.log("TTY\t: response(" + JSON.stringify(response) + ")");
144+
// console.log("TTY \t: response(" + JSON.stringify(response) + ")");
145145
},
146146
};
147147

js/firestep/planner.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ var MockFPD = require("./mock-fpd");
326326
if (!onDone) {
327327
onDone = function(data) {
328328
if (data.s) {
329-
console.log("TTY\t: FireStepPlanner: FireStep response:" + data.s);
329+
console.log("TTY \t: FireStepPlanner: FireStep response:" + data.s);
330330
}
331331
}
332332
}
@@ -347,7 +347,7 @@ var MockFPD = require("./mock-fpd");
347347
}
348348
that.driver.processQueue();
349349
if (that.driver.queueLength()) {
350-
console.log("TTY\t: FireStepPlanner.send() queued:", that.driver.queueLength());
350+
console.log("TTY \t: FireStepPlanner.send() queued:", that.driver.queueLength());
351351
}
352352
return that;
353353
}
@@ -396,7 +396,7 @@ var MockFPD = require("./mock-fpd");
396396
log: "FireStepPlanner.onIdle(initialized)"
397397
});
398398
} else {
399-
that.verbose && console.log("TTY\t: FireStepPlanner.onIdle(waiting) ...");
399+
that.verbose && console.log("TTY \t: FireStepPlanner.onIdle(waiting) ...");
400400
}
401401
if (that.mpoPlan) {
402402
that.model.mpo = that.model.mpo || {};

js/firestep/service.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ function millis() {
136136
}
137137
that.send(cmd, function(data) {
138138
var msElapsed = millis() - msStart;
139-
console.log("TTY\t: FireStepService.test(dvs) msElapsed:", msElapsed);
139+
console.log("TTY \t: FireStepService.test(dvs) msElapsed:", msElapsed);
140140
});
141141
that.send(that.cmd_mpo(), function(data) {
142142
var msElapsed = millis() - msStart;

js/firestep/tinyg-driver.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function mockAsync(callback) {
1616
var mockSerial = function(that, cmd) { // CANNOT BLOCK!!!
1717
that.model.writes = that.model.writes ? that.model.writes + 1 : 1;
1818
var serialData = JSON.stringify(cmd);
19-
console.log("TTY\t: WRITE(" + that.model.writes + ") " + serialData + "\\n");
19+
console.log("TTY \t: WRITE(" + that.model.writes + ") " + serialData + "\\n");
2020

2121
// SEND SERIAL DATA HERE
2222
if (cmd.hasOwnProperty("id")) { // identify machine
@@ -112,10 +112,10 @@ function mockAsync(callback) {
112112
};
113113
that.handlers = {
114114
idle: function() {
115-
// console.log("TTY\t: idle");
115+
// console.log("TTY \t: idle");
116116
},
117117
response: function(response) {
118-
// console.log("TTY\t: response(" + JSON.stringify(response) + ")");
118+
// console.log("TTY \t: response(" + JSON.stringify(response) + ")");
119119
},
120120
};
121121

@@ -194,7 +194,7 @@ function mockAsync(callback) {
194194
console.log("Config changed: " + util.inspect(changed));
195195
});
196196

197-
console.log("TTY\t: tinyg-driver: opened serial connection to:" + that.model.rest.serialPath);
197+
console.log("TTY \t: tinyg-driver: opened serial connection to:" + that.model.rest.serialPath);
198198

199199
// MAKE IT WORK OR THROW
200200
that.model.driver = that.name;
@@ -222,12 +222,12 @@ function mockAsync(callback) {
222222
var that = this;
223223

224224
if (that.serialQueue.length <= 0) {
225-
//console.log("TTY\t: TinyGDriver.processQueue(empty) ");
225+
//console.log("TTY \t: TinyGDriver.processQueue(empty) ");
226226
} else if (!that.model.available) {
227-
//console.log("TTY\t: TinyGDriver.processQueue(unavailable) ", that.serialQueue.length, " items");
227+
//console.log("TTY \t: TinyGDriver.processQueue(unavailable) ", that.serialQueue.length, " items");
228228
//console.log(that.serialQueue);
229229
} else if (that.serialInProgress) {
230-
//console.log("TTY\t: TinyGDriver.processQueue(busy) ", that.serialQueue.length, " items");
230+
//console.log("TTY \t: TinyGDriver.processQueue(busy) ", that.serialQueue.length, " items");
231231
//console.log(that.serialQueue);
232232
} else {
233233
that.serialInProgress = true;
@@ -240,7 +240,7 @@ function mockAsync(callback) {
240240
TinyGDriver.prototype.onSerialData = function(data) {
241241
var that = this;
242242
that.model.reads = that.model.reads ? that.model.reads + 1 : 1;
243-
console.log("TTY\t: READ(" + that.model.reads + ") " + data + "\\n");
243+
console.log("TTY \t: READ(" + that.model.reads + ") " + data + "\\n");
244244
var parsed = JSON.parse(data);
245245
var retData = parsed;
246246

js/server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var options = {
3232
version: {
3333
major: 0,
3434
minor: 18,
35-
patch: 0,
35+
patch: 1,
3636
},
3737
};
3838

scripts/startup.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,14 @@
33
scripts/shutdown.sh
44

55
pushd $(dirname "$0")/.. > /dev/null
6-
rm -f firenodejs.log
7-
echo -e "START\t: `pwd`/$0\t`date`" | tee -a firenodejs.log
6+
mkdir -p logs
7+
LOGNAME=logs/firenodejs`date +%F-%H%M`.log
8+
ln -sf $LOGNAME firenodejs.log
9+
echo -e "START\t: `pwd`/$0\t`date`" | tee $LOGNAME
10+
echo -e "INFO\t: logging to $LOGNAME" | tee -a $LOGNAME
811
echo -e "INFO\t: launching firenodejs server daemon as user:`whoami`" | tee -a firenodejs.log
9-
nohup ./node js/server.js $@ 0<&- &>> firenodejs.log &
12+
nohup ./node js/server.js $@ 0<&- &>> $LOGNAME &
1013
popd > /dev/null
11-
echo -e "END\t: `pwd`/$0\t`date`" | tee -a firenodejs.log
14+
echo -e "END \t: `pwd`/$0\t`date`" | tee -a $LOGNAME
1215

1316
exit 0

www/js/shared/Logger.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ var should = require("should");
132132
logLevel: "warn"
133133
});
134134
Logger.start = function(msg) {
135-
Logger.logger.write("START+" + (new Date() - msLaunch) + "ms\t: " + Logger.logger.message(arguments));
135+
Logger.logger.write("T+" + (new Date() - msLaunch) + "\t: " + Logger.logger.message(arguments));
136136
}
137137
Logger.validate = function(value) {
138138
should.exist(value);
@@ -145,7 +145,7 @@ var should = require("should");
145145
value.setLevel.should.be.a.function;
146146
}
147147
Logger.msLaunch = function() {
148-
return "T+" + (new Date() - msLaunch) + "ms";
148+
return "+" + (new Date() - msLaunch);
149149
}
150150

151151
module.exports = exports.Logger = Logger;

0 commit comments

Comments
 (0)