github.com/manicqin/nomad@v0.9.5/ui/app/utils/classes/abstract-logger.js (about)

     1  import { assert } from '@ember/debug';
     2  import Mixin from '@ember/object/mixin';
     3  import { computed } from '@ember/object';
     4  import { computed as overridable } from 'ember-overridable-computed';
     5  import { assign } from '@ember/polyfills';
     6  import queryString from 'query-string';
     7  
     8  const MAX_OUTPUT_LENGTH = 50000;
     9  
    10  export default Mixin.create({
    11    url: '',
    12    params: overridable(() => ({})),
    13    logFetch() {
    14      assert('Loggers need a logFetch method, which should have an interface like window.fetch');
    15    },
    16  
    17    endOffset: null,
    18  
    19    offsetParams: computed('endOffset', function() {
    20      const endOffset = this.endOffset;
    21      return endOffset
    22        ? { origin: 'start', offset: endOffset }
    23        : { origin: 'end', offset: MAX_OUTPUT_LENGTH };
    24    }),
    25  
    26    additionalParams: overridable(() => ({})),
    27  
    28    fullUrl: computed('url', 'params', 'offsetParams', 'additionalParams', function() {
    29      const queryParams = queryString.stringify(
    30        assign({}, this.params, this.offsetParams, this.additionalParams)
    31      );
    32      return `${this.url}?${queryParams}`;
    33    }),
    34  });