The problem
Hi,
I noticed a potential inconsistency in the logform documentation regarding custom formats created with format(fn).
The docs/examples imply that the returned value from format(fn) can be used directly with .transform(), but in practice it appears that format(fn) returns a factory function, and .transform only exists on an instantiated format.
Example:
const { format } = require('logform');
const ignorePrivate = format((info) => {
if (info.private) return false;
return info;
});
// This throws:
ignorePrivate.transform({ level: 'info', message: 'test' });
// TypeError: ignorePrivate.transform is not a function
Working version:
const instance = ignorePrivate();
instance.transform({ level: 'info', message: 'test' }, {});
Environment:
- Node.js: v20.11.1
- logform:
It seems the documentation/examples might suggest that .transform is directly available on the factory, which is not the case. Perhaps it would help to clarify that format(fn) returns a factory and must be invoked before .transform is available.
Thanks for the library and your work on it.
What version of Logform presents the issue?
2.7.0
What version of Node are you using?
20.11.1
If this is a TypeScript issue, what version of TypeScript are you using?
No response
If this worked in a previous version of Logform, which was it?
No response
Minimum Working Example
No response
Additional information
No response
🔎 Search Terms
Filtering info Objects, ignoPrivate docs example does not work
The problem
Hi,
I noticed a potential inconsistency in the logform documentation regarding custom formats created with
format(fn).The docs/examples imply that the returned value from
format(fn)can be used directly with.transform(), but in practice it appears thatformat(fn)returns a factory function, and.transformonly exists on an instantiated format.Example:
const { format } = require('logform');
const ignorePrivate = format((info) => {
if (info.private) return false;
return info;
});
// This throws:
ignorePrivate.transform({ level: 'info', message: 'test' });
// TypeError: ignorePrivate.transform is not a function
Working version:
const instance = ignorePrivate();
instance.transform({ level: 'info', message: 'test' }, {});
Environment:
It seems the documentation/examples might suggest that
.transformis directly available on the factory, which is not the case. Perhaps it would help to clarify thatformat(fn)returns a factory and must be invoked before.transformis available.Thanks for the library and your work on it.
What version of Logform presents the issue?
2.7.0
What version of Node are you using?
20.11.1
If this is a TypeScript issue, what version of TypeScript are you using?
No response
If this worked in a previous version of Logform, which was it?
No response
Minimum Working Example
No response
Additional information
No response
🔎 Search Terms
Filtering info Objects, ignoPrivate docs example does not work