// from the flitter/libflitter project - utility/services/Output.service.js/** * @module libflitter/utility/services/Output */const Service = require('../../NamedService')const color = require('colors/safe')/** * Service for managing output to the console based on logging level. * @extends module:flitter-di/src/Service~Service */class Output extends Service {  /**   * Get the name of this service: 'output'   * @returns {string} - 'output'   */  static get name() { return 'output' }  constructor() {    super()    /**     * The logging level.     * @type {number}     */    this.level = 1    /**     * If true, includes a timestamp in the output. Default false.     * @type {boolean}     */    this.timestamp = false  }  /**   * Get the trace name of the output method caller.   * Assumes that the caller is the fourth item in the stack.   * For example: Output.__get_caller_info < Output.__timestamp < Output.error < Original Caller   * @returns {string} - the caller's name (e.g. "ClassName.method")   * @private   */  __get_caller_info(level = 4) {    let inf = (new Error).stack      .split(/\sat\s/)      .slice(level)      .map(x => x.trim()        .split(' (')[0]        .split('.')[0]        .split(':')[0]      )[0]    if ( inf.indexOf('node_modules/') >= 0 ) inf = inf.split('node_modules/')[1]    if ( ['function', 'output'].includes(inf.toLowerCase()) ) return this.__get_caller_info(level + 2)    return inf  }  /**   * Get a color-formatted timestamp string.   * @returns {string}   * @private// from the flitter/libflitter project - utility/services/Output.service.js/** * @module libflitter/utility/services/Output */const Service = require('../../NamedService')const color = require('colors/safe')/** * Service for managing output to the console based on logging level. * @extends module:flitter-di/src/Service~Service */class Output extends Service {  /**   * Get the name of this service: 'output'   * @returns {string} - 'output'   */  static get name() { return 'output' }  constructor() {    super()    /**     * The logging level.     * @type {number}     */    this.level = 1    /**     * If true, includes a timestamp in the output. Default false.     * @type {boolean}     */    this.timestamp = false  }  /**   * Get the trace name of the output method caller.   * Assumes that the caller is the fourth item in the stack.   * For example: Output.__get_caller_info < Output.__timestamp < Output.error < Original Caller   * @returns {string} - the caller's name (e.g. "ClassName.method")   * @private   */  __get_caller_info(level = 4) {    let inf = (new Error).stack      .split(/\sat\s/)      .slice(level)      .map(x => x.trim()        .split(' (')[0]        .split('.')[0]        .split(':')[0]      )[0]    if ( inf.indexOf('node_modules/') >= 0 ) inf = inf.split('node_modules/')[1]    if ( ['function', 'output'].includes(inf.toLowerCase()) ) return this.__get_caller_info(level + 2)    return inf  }  /**   * Get a color-formatted timestamp string.   * @returns {string}   * @private// from the flitter/libflitter project - utility/services/Output.service.js/** * @module libflitter/utility/services/Output */const Service = require('../../NamedService')const color = require('colors/safe')/** * Service for managing output to the console based on logging level. * @extends module:flitter-di/src/Service~Service */class Output extends Service {  /**   * Get the name of this service: 'output'   * @returns {string} - 'output'   */  static get name() { return 'output' }  constructor() {    super()    /**     * The logging level.     * @type {number}     */    this.level = 1    /**     * If true, includes a timestamp in the output. Default false.     * @type {boolean}     */    this.timestamp = false  }  /**   * Get the trace name of the output method caller.   * Assumes that the caller is the fourth item in the stack.   * For example: Output.__get_caller_info < Output.__timestamp < Output.error < Original Caller   * @returns {string} - the caller's name (e.g. "ClassName.method")   * @private   */  __get_caller_info(level = 4) {    let inf = (new Error).stack      .split(/\sat\s/)      .slice(level)      .map(x => x.trim()        .split(' (')[0]        .split('.')[0]        .split(':')[0]      )[0]    if ( inf.indexOf('node_modules/') >= 0 ) inf = inf.split('node_modules/')[1]    if ( ['function', 'output'].includes(inf.toLowerCase()) ) return this.__get_caller_info(level + 2)    return inf  }  /**   * Get a color-formatted timestamp string.   * @returns {string}   * @private

Snippet: pdfsearch

Garrett Mills
Copyright © 2021 Garrett Mills