Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const allowedParams = ['allowClientCode', 'allowQueryStringCookies', 'chunkSize'
* @locus Client
* @class FilesCollection
* @param config {FilesCollectionConfig} - [anywhere] configuration object with the following properties:
* @param config.debug {boolean} - [anywhere] turn on/off debugging and extra logging
* @param config.debug {boolean|function} - [anywhere] Turn on/of debugging and extra logging to console, or pass your own function to handle debug messages on your own
* @param config.ddp {DDP.DDPStatic} - [client] custom DDP connection; object returned from `DDP.connect()`
* @param config.schema {object} - [anywhere] collection schema
* @param config.public {boolean} - [anywhere] store files in folder accessible for proxy servers, for limits, etc.
Expand Down Expand Up @@ -48,7 +48,7 @@ class FilesCollection extends FilesCollectionCore {
allowQueryStringCookies: this.allowQueryStringCookies,
});

if (!helpers.isBoolean(this.debug)) {
if (!helpers.isBoolean(this.debug) && !helpers.isFunction(this.debug)) {
this.debug = false;
}

Expand Down
4 changes: 3 additions & 1 deletion core.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,10 @@ export default class FilesCollectionCore extends EventEmitter {
*/
_debug(...args) {
if (this.debug) {
// if debug is truthy but not true it should be a function
const debugFn = this.debug === true ? null : this.debug;
// eslint-disable-next-line no-console
(console.info || console.log || function () {}).apply(undefined, args);
(debugFn || console.info || console.log || function () {}).apply(undefined, args);
}
}

Expand Down
4 changes: 2 additions & 2 deletions docs/constructor.md
Original file line number Diff line number Diff line change
Expand Up @@ -639,13 +639,13 @@
</tr>
<tr>
<td align="right">
<code>config.debug</code> {<em>Boolean</em>}
<code>config.debug</code> {<em>Boolean|Function</em>}
</td>
<td>
Isomorphic
</td>
<td>
Turn on/of debugging and extra logging
Turn on/off debugging and extra logging to console, or pass your own function to handle debug messages on your own
</td>
<td>
<code>false</code>
Expand Down
4 changes: 2 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const createIndex = async (_collection, keys, opts) => {
* @locus Server
* @class FilesCollection
* @param config {FilesCollectionConfig} - [Both] Configuration object with next properties:
* @param config.debug {boolean} - [Both] Turn on/of debugging and extra logging
* @param config.debug {boolean|function} - [Both] Turn on/off debugging and extra logging to console, or pass your own function to handle debug messages on your own
* @param config.schema {Object} - [Both] Collection Schema
* @param config.public {boolean} - [Both] Store files in folder accessible for proxy servers, for limits, and more - read docs
* @param config.strict {boolean} - [Server] Strict mode for partial content, if is `true` server will return `416` response code, when `range` is not specified, otherwise server return `206`
Expand Down Expand Up @@ -161,7 +161,7 @@ class FilesCollection extends FilesCollectionCore {

const self = this;

if (!helpers.isBoolean(this.debug)) {
if (!helpers.isBoolean(this.debug) && !helpers.isFunction(this.debug)) {
this.debug = false;
}

Expand Down