First Commit of new way of building the Platform

This commit is contained in:
Luis Fernando Molina committed 2020-01-28 17:27:23 +01:00
1 parent e48cf0dae5
commit 40e60b42cc
4616 files changed
+713402

No files matched your search

+35
View File
@@ -0,0 +1,35 @@
'use strict';
var enabled = require('enabled');
/**
* Bare minimum browser version of diagnostics. It doesn't need fancy pancy
* detection algorithms. The code is only enabled when *you* enable it for
* debugging purposes.
*
* @param {String} name Namespace of the diagnostics instance.
* @returns {Function} The logger.
* @api public
*/
module.exports = function factory(name) {
if (!enabled(name)) return function diagnopes() {};
return function diagnostics() {
var args = Array.prototype.slice.call(arguments, 0);
//
// We cannot push a value as first argument of the argument array as
// console's formatting %s, %d only works on the first argument it receives.
// So in order to prepend our namespace we need to override and prefix the
// first argument.
//
args[0] = name +': '+ args[0];
//
// So yea. IE8 doesn't have an apply so we need a work around to puke the
// arguments in place.
//
try { Function.prototype.apply.call(console.log, console, args); }
catch (e) {}
};
};
File diff suppressed because it is too large. Load diff
+49
View File
@@ -0,0 +1,49 @@
'use strict';
//
// Please run this example with the correct environment flag `DEBUG=*` or
// `DEBUG=big*` or what ever. For example:
//
// ```
// DEBUG=* node example.js
// ```
//
var log;
//
// Ignore this piece of code, it's merely here so we can use the `diagnostics`
// module if installed or just the index file of this repository which makes it
// easier to test. Normally you would just do:
//
// ```js
// var log = require('diagnostics');
// ```
//
// And everything will be find and dandy.
//
try { log = require('diagnostics'); }
catch (e) { log = require('./'); }
//
// In this example we're going to output a bunch on logs which are namespace.
// This gives a visual demonstration.
//
[
log('bigpipe'),
log('bigpipe:pagelet'),
log('bigpipe:page'),
log('bigpipe:page:rendering'),
log('bigpipe:primus:event'),
log('primus'),
log('primus:event'),
log('lexer'),
log('megatron'),
log('cows:moo'),
log('moo:moo'),
log('moo'),
log('helloworld'),
log('helloworld:bar')
].forEach(function (log) {
log('foo');
});
+106
View File
@@ -0,0 +1,106 @@
'use strict';
var colorspace = require('colorspace')
, enabled = require('enabled')
, kuler = require('kuler')
, util = require('util');
/**
* Check if the terminal we're using allows the use of colors.
*
* @type {Boolean}
* @private
*/
var tty = require('tty').isatty(1);
/**
* The default stream instance we should be writing against.
*
* @type {Stream}
* @public
*/
var stream = process.stdout;
/**
* A simple environment based logger.
*
* Options:
*
* - colors: Force the use of colors or forcefully disable them. If this option
* is not supplied the colors will be based on your terminal.
* - stream: The Stream instance we should write our logs to, defaults to
* process.stdout but can be anything you like.
*
* @param {String} name The namespace of your log function.
* @param {Object} options Logger configuration.
* @returns {Function} Configured logging method.
* @api public
*/
function factory(name, options) {
if (!enabled(name)) return function diagnopes() {};
options = options || {};
options.colors = 'colors' in options ? options.colors : tty;
options.ansi = options.colors ? kuler(name, colorspace(name)) : name;
options.stream = options.stream || stream;
//
// Allow multiple streams, so make sure it's an array which makes iteration
// easier.
//
if (!Array.isArray(options.stream)) {
options.stream = [options.stream];
}
//
// The actual debug function which does the logging magic.
//
return function debug(line) {
//
// Better formatting for error instances.
//
if (line instanceof Error) line = line.stack || line.message || line;
line = [
//
// Add the colorized namespace.
//
options.ansi,
//
// The total time we took to execute the next debug statement.
//
' ',
line
].join('');
//
// Use util.format so we can follow the same API as console.log.
//
line = util.format.apply(this, [line].concat(
Array.prototype.slice.call(arguments, 1)
)) + '\n';
options.stream.forEach(function each(stream) {
stream.write(line);
});
};
}
/**
* Override the "default" stream that we write to. This allows you to globally
* configure the steams.
*
* @param {Stream} output
* @returns {function} Factory
* @api private
*/
factory.to = function to(output) {
stream = output;
return factory;
};
//
// Expose the module.
//
module.exports = factory;
+85
View File
@@ -0,0 +1,85 @@
{
"_args": [
[
"diagnostics@1.1.1",
"C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer"
]
],
"_from": "diagnostics@1.1.1",
"_id": "diagnostics@1.1.1",
"_inBundle": false,
"_integrity": "sha512-8wn1PmdunLJ9Tqbx+Fx/ZEuHfJf4NKSN2ZBj7SJC/OWRWha843+WsTjqMe1B5E3p28jqBlp+mJ2fPVxPyNgYKQ==",
"_location": "/diagnostics",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "diagnostics@1.1.1",
"name": "diagnostics",
"escapedName": "diagnostics",
"rawSpec": "1.1.1",
"saveSpec": null,
"fetchSpec": "1.1.1"
},
"_requiredBy": [
"/winston"
],
"_resolved": "https://registry.npmjs.org/diagnostics/-/diagnostics-1.1.1.tgz",
"_spec": "1.1.1",
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer",
"author": {
"name": "Arnout Kazemier"
},
"browser": "./browser.js",
"bugs": {
"url": "https://github.com/bigpipe/diagnostics/issues"
},
"contributors": [
{
"name": "Martijn Swaagman",
"url": "https://github.com/swaagie"
},
{
"name": "Jarrett Cruger",
"url": "https://github.com/jcrugzz"
},
{
"name": "Sevastos",
"url": "https://github.com/sevastos"
}
],
"dependencies": {
"colorspace": "1.1.x",
"enabled": "1.0.x",
"kuler": "1.0.x"
},
"description": "Tools for debugging your node.js modules and event loop",
"devDependencies": {
"assume": "2.1.x",
"mocha": "5.2.x",
"pre-commit": "1.2.x"
},
"homepage": "https://github.com/bigpipe/diagnostics",
"keywords": [
"debug",
"debugger",
"debugging",
"diagnostic",
"diagnostics",
"event",
"loop",
"metrics",
"stats"
],
"license": "MIT",
"main": "index.js",
"name": "diagnostics",
"repository": {
"type": "git",
"url": "git://github.com/bigpipe/diagnostics.git"
},
"scripts": {
"test": "mocha --reporter spec --ui bdd test.js"
},
"version": "1.1.1"
}
+50
View File
@@ -0,0 +1,50 @@
describe('diagnostics', function () {
'use strict';
var assume = require('assume')
, debug = require('./');
beforeEach(function () {
process.env.DEBUG = '';
process.env.DIAGNOSTICS = '';
});
it('is exposed as function', function () {
assume(debug).to.be.a('function');
});
it('stringifies objects', function (next) {
process.env.DEBUG = 'test';
debug.to({
write: function write(line) {
assume(line).to.contain('test');
assume(line).to.contain('I will be readable { json: 1 }');
debug.to(process.stdout);
next();
}
});
debug('test')('I will be readable', { json: 1 });
});
describe('.to', function () {
it('globally overrides the stream', function (next) {
process.env.DEBUG = 'foo';
debug.to({
write: function write(line) {
assume(line).to.contain('foo');
assume(line).to.contain('bar');
debug.to(process.stdout);
next();
}
});
var log = debug('foo');
log('bar');
});
});
});