Skip to content

Commit b5a49bd

Browse files
committed
More log cleanup
1 parent dcd10b7 commit b5a49bd

17 files changed

+131
-123
lines changed

Astrometry.ts

-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ export default class Astrometry implements RequestHandler.APIAppProvider<BackOff
174174

175175
compute = async(ct: CancellationToken, message:BackOfficeAPI.AstrometryComputeRequest)=>{
176176
return await createTask<AstrometryResult>(ct, async (task) => {
177-
logger.info('Astrometry started', {image: message.image});
178177
if (this.currentProcess !== null) {
179178
throw new Error("Astrometry already in process");
180179
}

Camera.ts

-2
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,6 @@ export default class Camera
341341
}
342342

343343
setCamera=async (ct: CancellationToken, payload:{device:string})=>{
344-
logger.info('setCamera', payload);
345344
if (this.currentStatus.availableDevices.indexOf(payload.device) == -1) {
346345
throw "device not available";
347346
}
@@ -350,7 +349,6 @@ export default class Camera
350349

351350
setShootParam=async<K extends keyof CameraDeviceSettings> (ct: CancellationToken, payload:{camera?: string, key:K, value: CameraDeviceSettings[K]})=>{
352351
// FIXME: send the corresponding info ?
353-
logger.info('setShootParam',payload);
354352
var key = payload.key;
355353

356354
const deviceId = payload.camera !== undefined ? payload.camera : this.currentStatus.selectedDevice;

Indi.ts

+13-13
Original file line numberDiff line numberDiff line change
@@ -658,25 +658,25 @@ export class IndiConnection {
658658

659659
// var indiDevice = connection.getDevice("CCD Simulator");
660660

661-
// console.log('Waiting connection');
661+
// logger.debug('Waiting connection');
662662
// // connection.queueMessage('<newSwitchVector device="CCD Simulator" name="CONNECTION"><oneSwitch name="CONNECT" >On</oneSwitch></newSwitchVector>');
663663

664664
// var shoot = new Promises.Chain(
665665
// connection.wait(function() {
666666
// var status = connection.getDevice("CCD Simulator").getVector('CONNECTION').getPropertyValueIfExists('CONNECT');
667-
// console.log('Status is : ' + status);
667+
// logger.debug('Status is : ' + status);
668668
// if (status != 'On') return false;
669669

670670
// return connection.getDevice("CCD Simulator").getVector("CCD_EXPOSURE").getPropertyValueIfExists("CCD_EXPOSURE_VALUE") !== null;
671671
// }),
672672

673673
// new Promises.Immediate(() => {
674-
// console.log('Connection established');
674+
// logger.debug('Connection established');
675675
// connection.getDevice("CCD Simulator").getVector("CCD_EXPOSURE").setValues([{name: "CCD_EXPOSURE_VALUE", value: "10"}]);
676676
// }),
677677

678678
// connection.wait(function() {
679-
// console.log('Waiting for exposure end');
679+
// logger.debug('Waiting for exposure end');
680680
// var vector = connection.getDevice("CCD Simulator").getVector("CCD_EXPOSURE");
681681
// if (vector.getState() == "Busy") {
682682
// return false;
@@ -688,9 +688,9 @@ export class IndiConnection {
688688
// })
689689
// );
690690

691-
// shoot.then(function() { console.log('SHOOT: done'); });
692-
// shoot.onError(function(e) { console.log('SHOOT: error ' + e)});
693-
// shoot.onCancel(function() { console.log('SHOOT: canceled')});
691+
// shoot.then(function() { logger.debug('SHOOT: done'); });
692+
// shoot.onError(function(e) { logger.debug('SHOOT: error ' + e)});
693+
// shoot.onCancel(function() { logger.debug('SHOOT: canceled')});
694694
// shoot.start({});
695695

696696
// /* var status = getConnectionValue("CCD Simulator", 'CONNECTION');
@@ -701,25 +701,25 @@ export class IndiConnection {
701701
// connection.wait(function() {
702702
// return connection.properties['CONNECTION'].$$ == 'On';
703703
// }).then(function() {
704-
// console.log('connected !\n');
704+
// logger.debug('connected !\n');
705705
// });*/
706706

707707

708-
// var infinite = connection.wait(function() {console.log('checking dummy cond'); return false});
709-
// infinite.onCancel(function() { console.log('canceled !') });
708+
// var infinite = connection.wait(function() {logger.debug('checking dummy cond'); return false});
709+
// infinite.onCancel(function() { logger.debug('canceled !') });
710710

711711
// infinite = new Promises.Timeout(5000.0, infinite);
712-
// infinite.onError(console.warn);
712+
// infinite.onError(logger.warn);
713713
// infinite.start({});
714714

715715

716716

717717

718718

719-
// /* console.log('testing');
719+
// /* logger.debug('testing');
720720
// parser.write('<dummystartup>');
721721

722-
// console.log('test ok');
722+
// logger.debug('test ok');
723723

724724
// var xml = "<start><a>plop</a><b>glop</b>\n";
725725

IndiAutoGphotoSensorSize.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
import CancellationToken from 'cancellationtoken';
2+
import Log from './Log';
23
import IndiManager from './IndiManager';
34

4-
function debug(...args:any[]) {
5-
console.log('IndiAutoConnect: ' + args.map((e)=>''+e).join(' '));
6-
}
7-
5+
const logger = Log.logger(__filename);
86

97
// Evaluate f function, but if fail, return def
108
function noErr<T>(f:()=>T, def: T)
@@ -54,7 +52,7 @@ export default class IndiAutoGphotoSensorSize {
5452
// - busy, set the memory to done
5553
// - idle disconnected, connect
5654
// Remove the unknown devices from the memory
57-
debug('Recheck');
55+
logger.debug('Recheck');
5856
const configDevices = noErr(()=>this.indiManager.currentStatus.configuration.indiServer.devices, undefined) || {};
5957

6058
const configuredDevices:{[id:string]:boolean} = {};
@@ -65,7 +63,7 @@ export default class IndiAutoGphotoSensorSize {
6563
if (!noErr(()=>dev.options.autoGphotoSensorSize, undefined)) {
6664
continue;
6765
}
68-
debug('Configured device:', devId);
66+
logger.debug('Configured device', {devId});
6967
configuredDevices[devId] = true;
7068
}
7169

@@ -76,28 +74,23 @@ export default class IndiAutoGphotoSensorSize {
7674

7775
const deviceIds = c.getAvailableDeviceIdsWith([targetVector]);
7876

79-
debug('valid devices = ', JSON.stringify(deviceIds));
77+
logger.debug('valid devices', {deviceIds});
8078
for(let devId of deviceIds) {
81-
debug('What about', devId);
8279
if (!Object.prototype.hasOwnProperty.call(configuredDevices, devId)) {
83-
debug('Not configured');
8480
continue;
8581
}
8682

8783
// Check the connection state
8884
const connVector = c.getDevice(devId).getVector('CONNECTION');
8985
if (!connVector.exists()) {
90-
debug('CONNECTION does not exists');
9186
continue;
9287
}
9388

9489
if (connVector.getState() === 'Busy') {
95-
debug('CONNECTION is busy');
9690
continue;
9791
}
9892

9993
if (connVector.getPropertyValueIfExists('CONNECT') !== 'On') {
100-
debug('CONNECTION NOT On');
10194
continue;
10295
}
10396

@@ -106,25 +99,23 @@ export default class IndiAutoGphotoSensorSize {
10699

107100
const vector = c.getDevice(devId).getVector(targetVector);
108101
if (vector.getState() === 'Busy') {
109-
debug(targetVector, 'is busy');
110102
continue;
111103
}
112104

113105
const values = Object.keys(defaultValues).sort().map(k=>{
114106
const strValue = vector.getPropertyValueIfExists(k);
115107
return strValue === null ? null : parseFloat(strValue);
116108
});
117-
debug('Current values:', JSON.stringify(values));
109+
logger.debug('Current values', {devId, values});
118110

119111
if (values.filter(e=>(e!==0 && e !== null)).length === 0) {
120-
debug('Values are fine');
121112
continue;
122113
}
123114

124115
// Check the connection state of the device
125116
// Take memory state from the state of the connection vector
126117
const memoryState = Object.prototype.hasOwnProperty.call(this.memory, devId) ? this.memory[devId] : null;
127-
debug('Memory state is ', memoryState);
118+
logger.debug('Memory state ', {devId, memoryState});
128119
if (memoryState === true) {
129120
continue;
130121
}
@@ -133,17 +124,17 @@ export default class IndiAutoGphotoSensorSize {
133124

134125
(async ()=> {
135126
try {
136-
debug('Starting...');
127+
logger.info('Starting', {devId, defaultValues});
137128
await this.indiManager.setParam(CancellationToken.CONTINUE, devId, targetVector, defaultValues, true);
138129
} catch(e) {
139-
debug('Ignoring set size error', e);
130+
logger.warn('Ignoring set size error', {devId, defaultValues}, e);
140131
}
141132
})();
142133
}
143134
}
144135

145136
for(let devId of Object.keys(unseenDevices)) {
146-
debug('Forget about ', devId);
137+
logger.debug('Forget', {devId});
147138
delete this.memory[devId];
148139
}
149140
}

IndiMessageQueue.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
import Log from './Log';
12

3+
const logger = Log.logger(__filename);
24

35
type PendingMessage = {
46
// null means process asap
@@ -51,7 +53,7 @@ export class IndiMessageQueue {
5153
try {
5254
this.messageProcessor(head.message);
5355
} catch(e) {
54-
console.warn('indi message processing failed', e);
56+
logger.error('indi message processing failed', e);
5557
}
5658
break;
5759
}
@@ -186,7 +188,7 @@ export class IndiMessageQueue {
186188
if (existingMessagePos !== undefined) {
187189
this.messageQueue[existingMessagePos].message = message;
188190
if (this.messageQueue[existingMessagePos].fantom) {
189-
console.log(`Throttling INDI messages for ${message.$device}.${message.$name}`);
191+
logger.info('Throttling INDI messages', {op: message.$$, device: message.$device, name: message.$name});
190192
this.messageQueue[existingMessagePos].fantom = false;
191193
}
192194
} else {

Notification.ts

-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ export default class Notification
106106
}
107107

108108
public exposedNotification = async(ct: CancellationToken, message:BackOfficeAPI.ExposedNotificationRequest)=>{
109-
logger.info('Request for exposure of notification', message);
110109
const uid = message.uuid;
111110
if (has(this.currentStatus.byuuid, uid) && !has(this.expires, uid)) {
112111
if (this.currentStatus.byuuid[uid].type === "oneshot") {
@@ -116,7 +115,6 @@ export default class Notification
116115
}
117116

118117
public closeNotification = async(ct: CancellationToken, message:BackOfficeAPI.CloseNotificationRequest)=>{
119-
logger.info('CloseNotification for exposure of notification', message);
120118
const uid = message.uuid;
121119
if (has(this.currentStatus.byuuid, uid)) {
122120
const watcher = has(this.watchers, uid) ? this.watchers[uid]: undefined;

0 commit comments

Comments
 (0)