Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

We’re showing branches in this repository, but you can also compare across forks.

base fork: pfleidi/magnets
base: 5263280091
...
head fork: pfleidi/magnets
compare: 4180802a2e
  • 6 commits
  • 5 files changed
  • 0 commit comments
  • 2 contributors
1  .gitignore
View
@@ -2,3 +2,4 @@
*.jpg
log/
images/
+/node_modules
42 lib/colorappender.js
View
@@ -1,42 +0,0 @@
-var Style = require('./colored').foreground,
- Sys = require('sys');
-
-var LOGLEVELS = {
- TRACE: Style.blue,
- DEBUG: Style.green,
- INFO: Style.yellow,
- WARN: Style.magenta,
- ERROR: Style.red,
- FATAL: Style.red,
-};
-
-
-var basicLayout = function(loggingEvent) {
- var timestampLevelAndCategory = '[' + loggingEvent.startTime.toFormattedString() + '] ';
- var level = LOGLEVELS[loggingEvent.level.toString()](
- '[' + loggingEvent.level.toString() + '] '
- );
-
- timestampLevelAndCategory += level;
- timestampLevelAndCategory += loggingEvent.categoryName + ' - ';
-
- var output = timestampLevelAndCategory + loggingEvent.message;
-
- if (loggingEvent.exception) {
- output += '\n'
- output += timestampLevelAndCategory;
- if (loggingEvent.exception.stack) {
- output += loggingEvent.exception.stack;
- } else {
- output += loggingEvent.exception.name + ': '+loggingEvent.exception.message;
- }
- }
- return output;
-};
-
-exports.consoleAppender = function () {
- return function(loggingEvent) {
- Sys.puts(basicLayout(loggingEvent));
- };
-};
-
26 lib/magnetlib.js
View
@@ -12,10 +12,10 @@ Sys = require('sys'),
Url = require('url'),
Crypto = require('crypto'),
Log4js = require('log4js'),
-HttpClient = require('wwwdude'),
-Appender = require('./colorappender');
+HttpClient = require('wwwdude');
-Log4js.addAppender(Appender.consoleAppender());
+Log4js.loadAppender('console');
+Log4js.addAppender(Log4js.appenders.console());
var imageFolder = './images/', // TODO find a way to externally change this value!
newImagesFile = imageFolder + 'imageSum',
@@ -90,7 +90,7 @@ var httpGet = exports.httpGet = function httpGet(content, callback, encoding) {
image.data = data;
log.debug('Got image: ' + image);
callback(image);
- }).send();
+ }).emit();
};
/**
@@ -102,18 +102,12 @@ var httpGet = exports.httpGet = function httpGet(content, callback, encoding) {
* @return data to be written
*/
var appendData = exports.appendData = function appendData(file, data) {
- Fs.open(file, "a+", 0755, function (err, fd) {
- if (err) {
- throw err;
- }
- log.debug('appending ' + data + ' to ' + file);
- Fs.write(fd, data, function (err, written) {
- if (err) {
- throw err;
- }
- });
- Fs.close(fd);
- });
+ Fs.appendFile(file, data, function (err) {
+ if (err) {
+ throw err;
+ }
+ log.debug('appending ' + data + ' to ' + file);
+ });
};
7 magnets.js
View
@@ -12,8 +12,7 @@
var Mag = require('./lib/magnetlib'),
Fs = require('fs'),
Sys = require('sys'),
-Log4js = require('log4js'),
-Appender = require('./lib/colorappender.js');
+Log4js = require('log4js');
var modules = [],
PLUGIN_FOLDER = __dirname + "/plugins/",
@@ -21,8 +20,8 @@ LOGFILE = __dirname + '/log/magnets.log',
DEFAULT_TIMEOUT = 10000,
TIMEOUT = DEFAULT_TIMEOUT;
-//Log4js.addAppender(Appender.consoleAppender());
-Log4js.addAppender(Log4js.fileAppender(LOGFILE), 'magnets');
+Log4js.loadAppender('file');
+Log4js.addAppender(Log4js.appenders.file(LOGFILE), 'magnets');
var log = Log4js.getLogger('magnets');
log.setLevel('ERROR');
8 package.json
View
@@ -0,0 +1,8 @@
+{
+ "dependencies": {
+ "log4js": "*",
+ "wwwdude": "*",
+ "htmlparser": "*",
+ "soupselect": "*"
+ }
+}

No commit comments for this range

Something went wrong with that request. Please try again.