8000 Add `eventLayout` config option by ZachHaber · Pull Request #31 · log4js-node/logFaces-HTTP · GitHub
[go: up one dir, main page]

Skip to content

Add eventLayout config option #31

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

Merged
merged 7 commits into from
Jun 23, 2022
Merged

Conversation

ZachHaber
Copy link
Contributor

closes #1

eventLayout lets you have fine-grained control over what you are sending to the logfaces server.

For example, if you want relative file path names being sent in f instead of absolute:

log4js.configure({
  appenders: {
    logfaces: {
      type: "@log4js-node/logfaces-http",
      url: "http://lfs-server/logs",
      eventLayout: (event, lfEvent)=>{
        if(lfEvent.f){
          lfEvent.f = path.relative(path.resolve(), lfEvent.f);
        }
        return lfEvent;
      }
    },
  },
  categories: {
    default: { appenders: ["logfaces"], level: "info", enableCallStack: true },
  },
});

Or if you want to add commas between separate data entries:

{
  eventLayout: (event, lfEvent)=>({
    ...lfEvent,
    m: event.data.map(item=>util.format(item)).join(', ');
  })
}

@lamweili lamweili force-pushed the layout branch 7 times, most recently from fd621ca to 574447f Compare June 23, 2022 08:15
Zachary Haber and others added 2 commits June 23, 2022 17:29
`eventLayout` lets you have fine-grained control over what you are sending to the logfaces server.

Refs: log4js-node#1
@lamweili
Copy link
Contributor

I made some changes to the commits:

@lamweili lamweili added this to the 1.1.0 milestone Jun 23, 2022
@lamweili lamweili added the enhancement New feature or request label Jun 23, 2022
@lamweili
Copy link
Contributor

@ZachHaber This PR should be good to go once the review comments are addressed. 🤗

@ZachHaber ZachHaber requested a review from lamweili June 23, 2022 14:27
@lamweili
Copy link
Contributor

@ZachHaber Just a little more miscellaneous changes.

I tried to include most in suggestions so that you can Commit suggestion or Add suggestion to batch to make your life easier.
There is one for n which I'm not exactly sure the type which may require a manual commit.

Copy link
Contributor
@lamweili lamweili left a comment

Choose a reason for hiding this comment

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

@ZachHaber Thank you so much for this PR! LGTM!

@lamweili lamweili merged commit 07dbd73 into log4js-node:master Jun 23, 2022
@ZachHaber ZachHaber deleted the layout branch June 23, 2022 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

how can i layout message ?
2 participants
0