Skip to content
Browse files

Add ./dist

  • Loading branch information...
1 parent 1258018 commit 8839b415bd8c35cc702623bfcb9f67fef1ecb4e4 @mixu committed Jun 14, 2012
Showing with 113 additions and 1 deletion.
  1. +0 −1 .gitignore
  2. +1 −0 build.js
  3. +112 −0 dist/minilog.js
View
1 .gitignore
@@ -1,4 +1,3 @@
test/temp.log
node_modules/
test/example/hive
-dist/
View
1 build.js
@@ -15,4 +15,5 @@ new Glue()
fs.mkdirSync('./dist/');
}
fs.writeFileSync('./dist/minilog.js', txt);
+ console.log('Wrote ./dist/minilog.js');
});
View
112 dist/minilog.js
@@ -0,0 +1,112 @@
+(function(){var global = this;function require(p, parent){ var path = require.resolve(p) , mod = require.modules[path]; if (!mod) throw new Error('failed to require "' + p + '" from ' + parent); if (!mod.exports) { mod.exports = {}; mod.call(mod.exports, mod, mod.exports, require.relative(path), global); } return mod.exports;}require.modules = {};require.resolve = function(path){ var orig = path , reg = path + '.js' , index = path + '/index.js'; return require.modules[reg] && reg || require.modules[index] && index || orig;};require.relative = function(parent) { return function(p){ if ('debug' == p) return debug; if ('.' != p.charAt(0)) return require(p); var path = parent.split('/') , segs = p.split('/'); path.pop(); for (var i = 0; i < segs.length; i++) { var seg = segs[i]; if ('..' == seg) path.pop(); else if ('.' != seg) path.push(seg); } return require(path.join('/'), parent); };};
+require.modules["jquery"] = { exports: window.$ };
+require.modules['index.js'] = function(module, exports, require, global){
+exports = module.exports = require('./minilog.js');
+
+exports.backends = {
+// redis: require('./backends/redis.js'),
+// nodeConsole: require('./backends/node_console.js'),
+// jquery: require('./backends/jquery.js')
+ browser: require('./backends/browser_console.js')
+};
+
+};require.modules['minilog.js'] = function(module, exports, require, global){
+var callbacks = [],
+ log = { readable: true };
+
+log.on = log.addListener = function(ev, callback) {
+ callbacks[ev] || (callbacks[ev] = []);
+ callbacks[ev].unshift( callback );
+ return log;
+};
+
+log.emit = function(ev) {
+ if(!callbacks[ev]) return;
+ var args = Array.prototype.slice.call(arguments, 1);
+ for(var i = callbacks[ev].length-1; i >= 0; i--){
+ callbacks[ev][i] && callbacks[ev][i].apply(log, args);
+ }
+};
+
+log.removeListener = function(ev, callback) {
+ if(!callbacks[ev]) return;
+ for(var i = callbacks[ev].length-1; i >= 0; i--) {
+ if(callbacks[ev][i] == callback) {
+ callbacks[ev].splice(i, 1);
+ }
+ }
+};
+
+log.removeAllListeners = function(ev) {
+ delete callbacks[ev];
+};
+
+function serialize(args) {
+ var items = Array.prototype.slice.call(args);
+ if(!JSON || !JSON.stringify) return items;
+ for(var i = 0; i < items.length; i++) {
+ if(typeof items[i] == 'object') { items[i] = JSON.stringify(items[i]); }
+ }
+ return items;
+}
+
+exports = module.exports = function create(name) {
+ var o = function() { log.emit('item', name, undefined, serialize(arguments)); return o; };
+ o.debug = function() { log.emit('item', name, 'debug', serialize(arguments)); return o; };
+ o.info = function() { log.emit('item', name, 'info', serialize(arguments)); return o; };
+ o.warn = function() { log.emit('item', name, 'warn', serialize(arguments)); return o; };
+ o.error = function() { log.emit('item', name, 'error', serialize(arguments)); return o; };
+ return o;
+};
+
+exports.pipe = function(dest) {
+ var config = {};
+ log.on('item', function(name, level, args) {
+ if(config.filter && !config.filter(name, level)) {
+ return;
+ }
+ if(config.format) {
+ dest.write(config.format(name, level, args));
+ } else {
+ var prefix = [];
+ if(name) prefix.push(name);
+ if(level) prefix.push(level);
+ dest.write(prefix.concat(args).join(' ') + '\n');
+ }
+ }).on('end', function() { !dest._isStdio && dest.end(); });
+ var chain = {
+ filter: function(cb) { config.filter = cb; return chain; },
+ format: function(cb) { config.format = cb; return chain; },
+ pipe: exports.pipe
+ };
+ return chain;
+};
+
+exports.end = function() {
+ log.emit('end');
+ callbacks = [];
+};
+
+};require.modules['backends/browser_console.js'] = function(module, exports, require, global){
+module.exports = {
+ write: function(str) {
+ if (typeof console === 'undefined' || !console.log) return;
+ if (console.log.apply) {
+ // console.log.apply is undefined in IE8 and IE9
+ // and still useless for objects in IE9. But useful for non-IE browsers.
+ return console.log.apply(console, arguments);
+ }
+ if(!JSON || !JSON.stringify) return;
+ // for IE8/9: make console.log at least a bit less awful
+ var args = Array.prototype.slice.call(arguments),
+ len = args.length;
+ for(var i = 0; i < len; i++) {
+ args[i] = JSON.stringify(args[i]);
+ }
+ console.log(args.join(' '));
+ },
+ end: function() {}
+};
+
+};Minilog = require('index.js');
+})();

0 comments on commit 8839b41

Please sign in to comment.
Something went wrong with that request. Please try again.