0

我想LogDNA为我的log4js记录器创建一个附加程序,所以下面是我的代码。我遇到的问题是configure功能。实际上我不知道 的类型是什么,我知道它是一个函数但在typescriptlayouts中找不到它的类型:log4js

import { logDnaLogger } from './logging'
import * as log4js from 'log4js'

// This is the function that generates an appender function
function appender(layout: Function, timezoneOffset: string): Function {
    const appender = (loggingEvent: log4js.LoggingEvent): void => {
        logDnaLogger.info(`${layout(loggingEvent, timezoneOffset)}\n`)
    }

    appender.shutdown = (done: Function): void => {
        logDnaLogger.info('LOGDNA ------ SHUTDOWN')
        done()
    }

    return appender
}

function configure(config: log4js.Configuration, layouts: ??????????): Function {
    let layout = layouts.colouredLayout
    if (config.layout) {
        layout = layouts.layout(config.layout.type, config.layout)
    }
    //create a new appender instance
    return appender(layout, config.timezoneOffset)
}

export const logdnaAppender = { configure }

4

0 回答 0