Skip to content

Commit

Permalink
Safely reduce verbosity (famous last words)
Browse files Browse the repository at this point in the history
  • Loading branch information
martindale committed Feb 26, 2024
1 parent 14e416c commit 5a97e5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
20 changes: 17 additions & 3 deletions types/filesystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class Filesystem extends Actor {
this._state = {
actors: {},
content: {
files: []
files: [],
status: 'INITIALIZED'
},
documents: {}
};
Expand Down Expand Up @@ -128,11 +129,23 @@ class Filesystem extends Actor {
fs.writeFileSync(file, content);
return true;
} catch (exception) {
this.emit('error', `Could not write file: ${content}`);
this.emit('error', `Could not write file: ${content} ${exception}`);

Check warning on line 132 in types/filesystem.js

View check run for this annotation

Codecov / codecov/patch

types/filesystem.js#L132

Added line #L132 was not covered by tests
return false;
}
}

_handleDiskChange (type, filename) {
this.emit('file:update', {
name: filename,
type: type
});

// TODO: only sync changed files
// this._loadFromDisk();

return this;
}

Check warning on line 147 in types/filesystem.js

View check run for this annotation

Codecov / codecov/patch

types/filesystem.js#L138-L147

Added lines #L138 - L147 were not covered by tests

/**
* Load Filesystem state from disk.
* @returns {Promise} Resolves with Filesystem instance.
Expand Down Expand Up @@ -190,8 +203,9 @@ class Filesystem extends Actor {
}

async start () {
this._state.content.status = 'STARTING';
this.touchDir(this.path); // ensure exists
await this.sync();
this.sync();
return this;
}

Expand Down
4 changes: 2 additions & 2 deletions types/service.js
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ class Service extends Actor {
self.emit('debug', `[FABRIC:SERVICE] Source "${name}" emitted error: ${error}`);
}),
_handleLog: source.on('log', async function _handleTrustedLog (log) {
self.emit('log', `[FABRIC:SERVICE] Source "${name}" emitted log: ${log}`);
if (self.settings.debug) self.emit('log', `[FABRIC:SERVICE] Source "${name}" emitted log: ${log}`);

Check warning on line 409 in types/service.js

View check run for this annotation

Codecov / codecov/patch

types/service.js#L409

Added line #L409 was not covered by tests
}),
_handleMessage: source.on('message', async function (message) {
self.emit('debug', `[FABRIC:SERVICE] Source "${name}" emitted message: ${JSON.stringify(message.toObject ? message.toObject() : message, null, ' ')}`);
Expand All @@ -424,7 +424,7 @@ class Service extends Actor {
self.alert(`[FABRIC:SERVICE] New ${name} chaintip: ${hash}`);
}),
_handleWarning: source.on('warning', async function _handleTrustedWarning (warning) {
self.emit('warning', `[FABRIC:SERVICE] Source "${name}" emitted warning: ${warning}`);
if (self.settings?.verbosity >= 2) self.emit('warning', `[FABRIC:SERVICE] Source "${name}" emitted warning: ${warning}`);

Check warning on line 427 in types/service.js

View check run for this annotation

Codecov / codecov/patch

types/service.js#L427

Added line #L427 was not covered by tests
})
};
}
Expand Down

0 comments on commit 5a97e5b

Please sign in to comment.