github.com/Ilhicas/nomad@v1.0.4-0.20210304152020-e86851182bc3/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 // eslint-disable-next-line ember/no-new-mixins 11 export default Mixin.create({ 12 url: '', 13 params: overridable(() => ({})), 14 logFetch() { 15 assert('Loggers need a logFetch method, which should have an interface like window.fetch'); 16 }, 17 18 endOffset: null, 19 20 offsetParams: computed('endOffset', function() { 21 const endOffset = this.endOffset; 22 return endOffset 23 ? { origin: 'start', offset: endOffset } 24 : { origin: 'end', offset: MAX_OUTPUT_LENGTH }; 25 }), 26 27 additionalParams: overridable(() => ({})), 28 29 fullUrl: computed('url', 'params', 'offsetParams', 'additionalParams', function() { 30 const queryParams = queryString.stringify( 31 assign({}, this.params, this.offsetParams, this.additionalParams) 32 ); 33 return `${this.url}?${queryParams}`; 34 }), 35 });