github.com/emate/nomad@v0.8.2-wo-binpacking/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 { assign } from '@ember/polyfills'; 5 import queryString from 'npm:query-string'; 6 7 const MAX_OUTPUT_LENGTH = 50000; 8 9 export default Mixin.create({ 10 url: '', 11 params: computed(() => ({})), 12 logFetch() { 13 assert('Loggers need a logFetch method, which should have an interface like window.fetch'); 14 }, 15 16 endOffset: null, 17 18 offsetParams: computed('endOffset', function() { 19 const endOffset = this.get('endOffset'); 20 return endOffset 21 ? { origin: 'start', offset: endOffset } 22 : { origin: 'end', offset: MAX_OUTPUT_LENGTH }; 23 }), 24 25 additionalParams: computed(() => ({})), 26 27 fullUrl: computed('url', 'params', 'offsetParams', 'additionalParams', function() { 28 const queryParams = queryString.stringify( 29 assign({}, this.get('params'), this.get('offsetParams'), this.get('additionalParams')) 30 ); 31 return `${this.get('url')}?${queryParams}`; 32 }), 33 });