Skip to content

[docs inconsistancy]: format(fn) documentation suggests .transform is available without instantiation #347

@Alex57186

Description

@Alex57186

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions