Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Allow file to be a function #60

Merged
merged 1 commit into from
Mar 18, 2024
Merged

Conversation

FoxxMD
Copy link
Contributor

@FoxxMD FoxxMD commented Mar 6, 2024

Enables users to provide a function that dynamically changes the base log file name on roll

This PR supersedes #58

This solution is more elegant (IMO) as it does not add additional options.


Particularly useful if a user prefers timestamp-based file names rather than pure numbers IE

const rollingDest = await pinoRoll({
    file: () => `${path.resolve(logPath, 'app')}-${dayjs().format('YYYY-MM-DD')}`,
    size: 10,
    frequency: 'daily',
    extension: '.log',
    mkdir: true
});

So that file names look like:

app-2024-02-21.1.log
app-2024-02-22.1.log
app-2024-02-23.1.log
app-2024-02-23.2.log

Enables users to provide a function that dynamically changes the base log file name on roll
@FoxxMD
Copy link
Contributor Author

FoxxMD commented Mar 18, 2024

Hi @feugy is this on your radar at all? Please let me know if there's something blocking this.

Copy link
Owner

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@mcollina mcollina merged commit f1004e7 into mcollina:main Mar 18, 2024
9 checks passed
FoxxMD added a commit to FoxxMD/logging that referenced this pull request Mar 19, 2024
Replace scoped package with official package with merged PR mcollina/pino-roll#60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants