1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2025-09-06 04:48:01 +00:00

Expand the logging mechanism to support alerts overlaid on the main screen

Now we get decent visual indication of sync errors, for instance. Still
work to do to coalesce alerts so that the screen doesn’t fill up with
them after an interval. And probably we should add a button to clear
all alerts.
This commit is contained in:
Jermolene
2014-02-14 07:53:41 +00:00
parent 28212f08b2
commit 70a120d4a6
12 changed files with 118 additions and 70 deletions

View File

@@ -21,12 +21,12 @@ function FileSystemAdaptor(syncer) {
this.syncer = syncer;
this.watchers = {};
this.pending = {};
this.log = $tw.logger.makeLog("FileSystem");
this.logger = new $tw.utils.Logger("FileSystem");
this.setwatcher = function(filename, title) {
return undefined;
return this.watchers[filename] = this.watchers[filename] ||
fs.watch(filename, {persistent: false}, function(e) {
self.log("Error:",e,filename);
self.logger.log("Error:",e,filename);
if(e === "change") {
var tiddlers = $tw.loadTiddlersFromFile(filename).tiddlers;
for(var t in tiddlers) {
@@ -157,7 +157,7 @@ FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback) {
if(err) {
return callback(err);
}
self.log("Saved file",fileInfo.filepath);
self.logger.log("Saved file",fileInfo.filepath);
_finish();
});
});
@@ -169,7 +169,7 @@ FileSystemAdaptor.prototype.saveTiddler = function(tiddler,callback) {
if(err) {
return callback(err);
}
self.log("Saved file",fileInfo.filepath);
self.logger.log("Saved file",fileInfo.filepath);
_finish();
});
}
@@ -203,7 +203,7 @@ FileSystemAdaptor.prototype.deleteTiddler = function(title,callback) {
if(err) {
return callback(err);
}
self.log("Deleted file",fileInfo.filepath);
self.logger.log("Deleted file",fileInfo.filepath);
// Delete the metafile if present
if(fileInfo.hasMetaFile) {
fs.unlink(fileInfo.filepath + ".meta",function(err) {

View File

@@ -19,7 +19,7 @@ function TiddlyWebAdaptor(syncer) {
this.syncer = syncer;
this.host = this.getHost();
this.recipe = undefined;
this.log = $tw.logger.makeLog("TiddlyWebAdaptor");
this.logger = new $tw.utils.Logger("TiddlyWebAdaptor");
}
TiddlyWebAdaptor.prototype.getHost = function() {
@@ -48,7 +48,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
// Get status
var self = this,
wiki = self.syncer.wiki;
this.log("Getting status");
this.logger.log("Getting status");
$tw.utils.httpRequest({
url: this.host + "status",
callback: function(err,data) {
@@ -63,7 +63,7 @@ TiddlyWebAdaptor.prototype.getStatus = function(callback) {
} catch (e) {
}
if(json) {
self.log("Status:",data);
self.logger.log("Status:",data);
// Record the recipe
if(json.space) {
self.recipe = json.space.recipe;
@@ -95,7 +95,7 @@ TiddlyWebAdaptor.prototype.login = function(username,password,callback) {
callback(err);
}
};
this.log("Logging in:",options);
this.logger.log("Logging in:",options);
$tw.utils.httpRequest(options);
};
@@ -113,7 +113,7 @@ TiddlyWebAdaptor.prototype.logout = function(callback) {
callback(err);
}
};
this.log("Logging out:",options);
this.logger.log("Logging out:",options);
$tw.utils.httpRequest(options);
};