aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorJames Barnett <noreply@jamesbarnett.xyz>2019-01-26 11:32:39 +0000
committerJames Barnett <noreply@jamesbarnett.xyz>2019-01-26 11:32:39 +0000
commit5961038eb295ed1776919947750154528b304d06 (patch)
tree4b3bbe9c2015f6173471ca7f5d602b2394bc64ea /services
parent7a50ab0610ec77f75568ffa2a6754b120655b112 (diff)
downloadtplink-energy-monitor-5961038eb295ed1776919947750154528b304d06.tar.xz
tplink-energy-monitor-5961038eb295ed1776919947750154528b304d06.zip
Fix sync write error handling
Diffstat (limited to 'services')
-rw-r--r--services/data-logger.js12
1 files changed, 7 insertions, 5 deletions
diff --git a/services/data-logger.js b/services/data-logger.js
index f4f4865..700bed0 100644
--- a/services/data-logger.js
+++ b/services/data-logger.js
@@ -43,11 +43,13 @@ function startLogging(device) {
}
function writeLog(filePath, log) {
- fs.writeFileSync(filePath, JSON.stringify(log), { flag: 'w' }, (err) => {
- if (err) {
- console.warn('Error writing log for ' + device.alias + ' [' + device.deviceId + ']', err);
- }
- });
+ try {
+ // Switched to sync write for now. TODO investigate issue from PR #19
+ fs.writeFileSync(filePath, JSON.stringify(log), { flag: 'w' });
+ }
+ catch (err) {
+ console.warn('Error writing log for ' + device.alias + ' [' + device.deviceId + ']', err);
+ }
}
function getLogEntries(filePath, callback) {