Skip to content

Inconsistency regarding configure signature of AppenderModule with typescript #1292

@ofekisr

Description

@ofekisr

There is some inconsistency between the documentation and typescript types
regarding the configure signature of AppenderModule and there is no findAppender declaration in log4js.d.ts

What do you think?

please review the three states below:

from: appenders Advanced configuration doc - configure defined with four arguments

const myAppenderModule = {
  configure: (config, layouts, findAppender, levels) => {
    /* ...your appender config... */
  },
};
log4js.configure({
  appenders: { custom: { type: myAppenderModule } },
  categories: { default: { appenders: ["custom"], level: "debug" } },
});

from: writing appenders doc - configure defined with only two arguments

// This is the function that generates an appender function
function stdoutAppender(layout, timezoneOffset) {
  // This is the appender function itself
  return (loggingEvent) => {
    process.stdout.write(`${layout(loggingEvent, timezoneOffset)}\n`);
  };
}

// stdout configure doesn't need to use findAppender, or levels
function configure(config, layouts) {
  // the default layout for the appender
  let layout = layouts.colouredLayout;
  // check if there is another layout specified
  if (config.layout) {
    // load the layout
    layout = layouts.layout(config.layout.type, config.layout);
  }
  //create a new appender instance
  return stdoutAppender(layout, config.timezoneOffset);
}

//export the only function needed
exports.configure = configure;

from: https://github.com/log4js-node/log4js-node/blob/master/types/log4js.d.ts - configure defined without findAppender
there is no declaration of findAppender - I can't defined my own Appender as middleware Appender - I can't reach the next appenders

export interface CustomAppender {
  type: string | AppenderModule;
  [key: string]: any;
}

export interface AppenderModule {
  configure: (config: Config, layouts: LayoutsParam) => AppenderFunction;
}

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