fix: Fixing logger for custom S3 stream (#3900)
* fix: Fixing logger for custom S3 stream * fix: adjusting s3 stream folder * fix: fixing forcedPathStyle variable name. * Update logger.ts * add S3ClientConfig types --------- Co-authored-by: Henry Heng <henryheng@flowiseai.com>
This commit is contained in:
parent
3fc4e79089
commit
4c9d46d7e5
|
|
@ -4,6 +4,7 @@ import { hostname } from 'node:os'
|
|||
import config from './config' // should be replaced by node-config or similar
|
||||
import { createLogger, transports, format } from 'winston'
|
||||
import { NextFunction, Request, Response } from 'express'
|
||||
import { S3ClientConfig } from '@aws-sdk/client-s3'
|
||||
|
||||
const { S3StreamLogger } = require('s3-streamlogger')
|
||||
|
||||
|
|
@ -17,32 +18,38 @@ if (process.env.STORAGE_TYPE === 's3') {
|
|||
const secretAccessKey = process.env.S3_STORAGE_SECRET_ACCESS_KEY
|
||||
const region = process.env.S3_STORAGE_REGION
|
||||
const s3Bucket = process.env.S3_STORAGE_BUCKET_NAME
|
||||
const customURL = process.env.S3_ENDPOINT_URL
|
||||
const forcePathStyle = process.env.S3_FORCE_PATH_STYLE === 'true'
|
||||
|
||||
const s3Config: S3ClientConfig = {
|
||||
region: region,
|
||||
endpoint: customURL,
|
||||
forcePathStyle: forcePathStyle,
|
||||
credentials: {
|
||||
accessKeyId: accessKeyId as string,
|
||||
secretAccessKey: secretAccessKey as string
|
||||
}
|
||||
}
|
||||
|
||||
s3ServerStream = new S3StreamLogger({
|
||||
bucket: s3Bucket,
|
||||
folder: 'logs/server',
|
||||
region,
|
||||
access_key_id: accessKeyId,
|
||||
secret_access_key: secretAccessKey,
|
||||
name_format: `server-%Y-%m-%d-%H-%M-%S-%L-${hostname()}.log`
|
||||
name_format: `server-%Y-%m-%d-%H-%M-%S-%L-${hostname()}.log`,
|
||||
config: s3Config
|
||||
})
|
||||
|
||||
s3ErrorStream = new S3StreamLogger({
|
||||
bucket: s3Bucket,
|
||||
folder: 'logs/error',
|
||||
region,
|
||||
access_key_id: accessKeyId,
|
||||
secret_access_key: secretAccessKey,
|
||||
name_format: `server-error-%Y-%m-%d-%H-%M-%S-%L-${hostname()}.log`
|
||||
name_format: `server-error-%Y-%m-%d-%H-%M-%S-%L-${hostname()}.log`,
|
||||
config: s3Config
|
||||
})
|
||||
|
||||
s3ServerReqStream = new S3StreamLogger({
|
||||
bucket: s3Bucket,
|
||||
folder: 'logs/requests',
|
||||
region,
|
||||
access_key_id: accessKeyId,
|
||||
secret_access_key: secretAccessKey,
|
||||
name_format: `server-requests-%Y-%m-%d-%H-%M-%S-%L-${hostname()}.log.jsonl`
|
||||
name_format: `server-requests-%Y-%m-%d-%H-%M-%S-%L-${hostname()}.log.jsonl`,
|
||||
config: s3Config
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue