-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
242 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import Transport from "winston-transport"; | ||
import { S3Client } from "@aws-sdk/client-s3"; | ||
import { LogGroup, Options, S3TransportConfig } from "./index.interface"; | ||
declare class S3Transport extends Transport { | ||
logGroups: Record<string, LogGroup>; | ||
s3Client: S3Client; | ||
s3TransportConfig: Required<S3TransportConfig>; | ||
constructor(options: Options); | ||
updateLogGroupList(logGroupIdList?: string[]): Promise<boolean>; | ||
/** | ||
* Create bucket path | ||
*/ | ||
static createBucketPath(groupId: string, s3TransportConfig: S3TransportConfig): string; | ||
/** | ||
* Create log group | ||
*/ | ||
static createLogGroup(groupId: string, s3TransportConfig: S3TransportConfig): LogGroup; | ||
log(logInfo: any, callback: any): Promise<void>; | ||
static calcDataSize(data: any): number; | ||
/** | ||
* Upload data to s3 bucket | ||
*/ | ||
static uploadToS3Bucket(s3Client: S3Client, bucket: string, bucketPath: string, data: any[], compress?: boolean): Promise<boolean>; | ||
} | ||
export default S3Transport; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Transport from "winston-transport"; | ||
import { S3ClientConfig } from "@aws-sdk/client-s3"; | ||
export interface LogGroup { | ||
data: any[]; | ||
bucket: string; | ||
bucketPath: string; | ||
createdTime: Date; | ||
isUpdated: boolean; | ||
uploadTime?: Date; | ||
} | ||
export interface S3TransportConfig { | ||
bucket: string; | ||
bucketPath: ((groupId: string) => string) | string; | ||
group?: (<T = any>(logInfo: T) => string) | string; | ||
/** | ||
* @deprecated Use group instead of groupId. | ||
*/ | ||
groupId?: (<T = any>(logInfo: T) => string) | string; | ||
dataUploadInterval?: number; | ||
maxDataSize?: number; | ||
fileRotationInterval?: number; | ||
gzip?: boolean; | ||
} | ||
export interface Options extends Transport.TransportStreamOptions { | ||
/** | ||
* @see https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/clients/client-s3/interfaces/s3clientconfig.html | ||
*/ | ||
s3ClientConfig: S3ClientConfig; | ||
s3TransportConfig: S3TransportConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
Oops, something went wrong.