Skip to content

Commit

Permalink
Some code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
tomas committed Jul 9, 2012
1 parent 8556e75 commit 2798d12
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
22 changes: 11 additions & 11 deletions lib/prey/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,16 @@ var Agent = self = {
logger.info('[agent] ' + str);
},

log_error: function(err){
logger.error("[agent] " + err.toString());
logger.debug(err.stack);
hooks.trigger('error', err.toString());
},

get_running_user: function(){
return process.env.USER || process.env.USERNAME || 'System';
},

run: function(){

if(this.running) return false;
Expand Down Expand Up @@ -78,10 +88,6 @@ var Agent = self = {

},

get_running_user: function(){
return process.env.USER || process.env.USERNAME || 'System';
},

initialize: function(callback){

this.running = true;
Expand Down Expand Up @@ -136,7 +142,7 @@ var Agent = self = {
logger.info('[agent] Checking connection...');

var no_connection = function(e){
logger.warn("[agent] No connection found after " + attempts + " attempts.");
logger.warn("[agent] No connection found after " + attempt + " attempts.");
hooks.trigger('no_conection');
if(callback) callback(false);
}
Expand Down Expand Up @@ -175,12 +181,6 @@ var Agent = self = {

},

log_error: function(err){
logger.error("[agent] " + err.toString());
logger.debug(err.stack);
hooks.trigger('error', err.toString());
},

load_driver: function(driver_name, driver_options){

loader.load_driver(driver_name, function(err, driver_module){
Expand Down
6 changes: 2 additions & 4 deletions lib/prey/hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//////////////////////////////////////////
// Prey JS Hook Relay
// (c) 2011, Fork Ltd. -- forkhq.com
// (c) 2012, Fork Ltd. -- forkhq.com
// Written by Tomás Pollak
// Licensed under the GPLv3
//////////////////////////////////////////
Expand All @@ -18,7 +18,7 @@ function Hooks(){
this.log = function(str){
logger.notice("[hooks] " + str);
};

this.on('error', function(err){
// this prevents the infamous Uncaught, unspecified 'error' event
})
Expand Down Expand Up @@ -65,11 +65,9 @@ function Hooks(){
};

this.unregister = function(hook){

this.log("Unregistering hook: " + hook);
this.removeAllListeners(hook);
this.remove_from_list(hook);

};

this.remove_from_list = function(hook){
Expand Down

0 comments on commit 2798d12

Please sign in to comment.