Verzeichnisstruktur phpBB-3.3.16


Veröffentlicht
27.04.2026

So funktioniert es


Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück

Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

      (Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

Logger.js

Zuletzt modifiziert: 01.05.2026, 11:27 - Dateigröße: 2.99 KiB


 001  /**
 002  * @constructor
 003  */
 004  function Logger()
 005  {
 006      this.callbacks = {};
 007      this.logs      = [];
 008  }
 009   
 010  /**
 011  * @type {string} Name of the attribute being processed
 012  */
 013  Logger.prototype.attrName;
 014   
 015  /**
 016  * @type {!Object.<string,!Array>} 2D array of [<log type> => [<callbacks>]]
 017  */
 018  Logger.prototype.callbacks;
 019   
 020  /**
 021  * @type {!Array.<!Array>} Log entries in the form [[<type>,<msg>,<context>]]
 022  */
 023  Logger.prototype.logs;
 024   
 025  /**
 026  * @type {?Tag} Tag being processed
 027  */
 028  Logger.prototype.tag;
 029   
 030  /**
 031  * Add a log entry
 032  *
 033  * @param  {string}   type    Log type
 034  * @param  {string}   msg     Log message
 035  * @param  {!Object=} context Log context
 036  */
 037  Logger.prototype.add = function(type, msg, context)
 038  {
 039      context = context || {};
 040   
 041      if (!('attrName' in context) && this.attrName)
 042      {
 043          context['attrName'] = this.attrName;
 044      }
 045   
 046      if (!('tag' in context) && this.tag)
 047      {
 048          context['tag'] = this.tag;
 049      }
 050   
 051      // Execute callbacks
 052      if (this.callbacks[type])
 053      {
 054          this.callbacks[type].forEach(function(callback)
 055          {
 056              callback(msg, context);
 057          });
 058      }
 059   
 060      this.logs.push([type, msg, context]);
 061  };
 062   
 063  /**
 064  * Clear the log
 065  */
 066  Logger.prototype.clear = function()
 067  {
 068      this.logs = [];
 069      this.unsetAttribute();
 070      this.unsetTag();
 071  };
 072   
 073  /**
 074  * Return the logs
 075  *
 076  * @return {!Object}
 077  */
 078  Logger.prototype['getLogs'] = function()
 079  {
 080      return this.logs;
 081  };
 082   
 083  /**
 084  * Attach a callback to be executed when a message of given type is logged
 085  *
 086  * @param {string}    type     Log type
 087  * @param {!Function} callback Callback
 088  */
 089  Logger.prototype['on'] = function(type, callback)
 090  {
 091      this.callbacks[type].push(callback);
 092  };
 093   
 094  /**
 095  * Record the name of the attribute being processed
 096  *
 097  * @param {string} attrName
 098  */
 099  Logger.prototype.setAttribute = function(attrName)
 100  {
 101      this.attrName = attrName;
 102  };
 103   
 104  /**
 105  * Record the tag being processed
 106  *
 107  * @param {!Tag} tag
 108  */
 109  Logger.prototype.setTag = function(tag)
 110  {
 111      this.tag = tag;
 112  };
 113   
 114  /**
 115  * Unset the name of the attribute being processed
 116  */
 117  Logger.prototype.unsetAttribute = function()
 118  {
 119      delete this.attrName;
 120  };
 121   
 122  /**
 123  * Unset the tag being processed
 124  */
 125  Logger.prototype.unsetTag = function()
 126  {
 127      delete this.tag;
 128  };
 129   
 130  //==========================================================================
 131  // Log levels
 132  //==========================================================================
 133   
 134  /**
 135  * Add a "debug" type log entry
 136  *
 137  * @param  {string}   msg     Log message
 138  * @param  {!Object=} context Log context
 139  */
 140  Logger.prototype.debug = function(msg, context)
 141  {
 142      this.add('debug', msg, context);
 143  };
 144   
 145  /**
 146  * Add an "err" type log entry
 147  *
 148  * @param  {string}   msg     Log message
 149  * @param  {!Object=} context Log context
 150  */
 151  Logger.prototype.err = function(msg, context)
 152  {
 153      this.add('err', msg, context);
 154  };
 155   
 156  /**
 157  * Add an "info" type log entry
 158  *
 159  * @param  {string}   msg     Log message
 160  * @param  {!Object=} context Log context
 161  */
 162  Logger.prototype.info = function(msg, context)
 163  {
 164      this.add('info', msg, context);
 165  };
 166   
 167  /**
 168  * Add a "warn" type log entry
 169  *
 170  * @param  {string}   msg     Log message
 171  * @param  {!Object=} context Log context
 172  */
 173  Logger.prototype.warn = function(msg, context)
 174  {
 175      this.add('warn', msg, context);
 176  };