(config)
| 7 | |
| 8 | class SeqLogger { |
| 9 | constructor(config) { |
| 10 | let dflt = { |
| 11 | serverUrl: 'http://localhost:5341', |
| 12 | apiKey: null, |
| 13 | maxBatchingTime: 2000, |
| 14 | eventSizeLimit: 256 * 1024, |
| 15 | batchSizeLimit: 1024 * 1024, |
| 16 | requestTimeout: 30000, |
| 17 | maxRetries: 5, |
| 18 | retryDelay: 5000, |
| 19 | onError: e => { |
| 20 | console.error("[seq]", e); |
| 21 | } |
| 22 | }; |
| 23 | let cfg = config || dflt; |
| 24 | var serverUrl = cfg.serverUrl || dflt.serverUrl; |
| 25 | if (!serverUrl.endsWith('/')) { |
| 26 | serverUrl += '/'; |
| 27 | } |
| 28 | this._endpoint = serverUrl + 'api/events/raw'; |
| 29 | this._apiKey = cfg.apiKey || dflt.apiKey; |
| 30 | this._maxBatchingTime = cfg.maxBatchingTime || dflt.maxBatchingTime; |
| 31 | this._eventSizeLimit = cfg.eventSizeLimit || dflt.eventSizeLimit; |
| 32 | this._batchSizeLimit = cfg.batchSizeLimit || dflt.batchSizeLimit; |
| 33 | this._requestTimeout = cfg.requestTimeout || dflt.requestTimeout; |
| 34 | this._onError = cfg.onError || dflt.onError; |
| 35 | this._maxRetries = cfg.maxRetries || dflt.maxRetries; |
| 36 | this._retryDelay = cfg.retryDelay || dflt.retryDelay; |
| 37 | |
| 38 | this._queue = []; |
| 39 | this._timer = null; |
| 40 | this._closed = false; |
| 41 | this._activeShipper = null; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * Flush events queued at the time of the call, and wait for pending writes to complete regardless of configured batching/timers. |
nothing calls this directly
no outgoing calls
no test coverage detected