MCPcopy Create free account
hub / github.com/PrairieLearn/PrairieLearn / debug

Function debug

public/javascripts/socket.io.js:731–798  ·  view source on GitHub ↗

* Create a debugger with the given `namespace`. * * @param {String} namespace * @return {Function} * @api public

(namespace)

Source from the content-addressed store, hash-verified

729 */
730
731 function debug(namespace) {
732
733 // define the `disabled` version
734 function disabled() {
735 }
736 disabled.enabled = false;
737
738 // define the `enabled` version
739 function enabled() {
740
741 var self = enabled;
742
743 // set `diff` timestamp
744 var curr = +new Date();
745 var ms = curr - (prevTime || curr);
746 self.diff = ms;
747 self.prev = prevTime;
748 self.curr = curr;
749 prevTime = curr;
750
751 // add the `color` if not set
752 if (null == self.useColors) self.useColors = exports.useColors();
753 if (null == self.color && self.useColors) self.color = selectColor();
754
755 var args = new Array(arguments.length);
756 for (var i = 0; i < args.length; i++) {
757 args[i] = arguments[i];
758 }
759
760 args[0] = exports.coerce(args[0]);
761
762 if ('string' !== typeof args[0]) {
763 // anything else let's inspect with %o
764 args = ['%o'].concat(args);
765 }
766
767 // apply any `formatters` transformations
768 var index = 0;
769 args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
770 // if we encounter an escaped % then don't increase the array index
771 if (match === '%%') return match;
772 index++;
773 var formatter = exports.formatters[format];
774 if ('function' === typeof formatter) {
775 var val = args[index];
776 match = formatter.call(self, val);
777
778 // now we need to remove `args[index]` since it's inlined in the `format`
779 args.splice(index, 1);
780 index--;
781 }
782 return match;
783 });
784
785 // apply env-specific formatting
786 args = exports.formatArgs.apply(self, args);
787
788 var logFn = enabled.log || exports.log || console.log.bind(console);

Callers 15

lookupFunction · 0.85
urlFunction · 0.85
socket.io.jsFile · 0.85
encodeAsStringFunction · 0.85
decodeStringFunction · 0.85
onTransportOpenFunction · 0.85
onerrorFunction · 0.85
onupgradeFunction · 0.85
closeFunction · 0.85
pauseFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected