UNPKG

winston-azure-blob

Version:

NEW winston transport for azure blob storage

66 lines 2.39 kB
/// <reference types="node" /> import Transport from "winston-transport"; import { BlobServiceClient } from "@azure/storage-blob"; import type { LogEntry } from "winston"; /** * Azure storage account credential variants */ declare type Account = { name: string; key: string; } | { host: string; sasToken: string; } | { connectionString: string; }; /** * File extensions for the log file. More can be added */ export declare enum extensions { LOG = ".log" } export interface IWinstonAzureBlob { account: Account; blobName: string; bufferLogSize: number; containerName: string; eol: string; extension?: extensions | string; headers?: Array<string>; rotatePeriod: string; syncTimeout: number; timeoutFn?: NodeJS.Timeout | null; } /** * Default options for AzureBlob */ export declare type ILoggerDefaults = Pick<IWinstonAzureBlob, "bufferLogSize" | "eol" | "extension" | "rotatePeriod" | "syncTimeout">; export declare class WinstonAzureBlob extends Transport implements IWinstonAzureBlob { account: Account; azBlobClient: BlobServiceClient; blobName: string; buffer: Array<LogEntry>; bufferLogSize: number; containerName: string; eol: string; extension?: extensions | string; rotatePeriod: string; syncTimeout: number; timeoutFn: NodeJS.Timeout | null; headers?: Array<string>; constructor(opts: Transport.TransportStreamOptions & Omit<IWinstonAzureBlob, keyof ILoggerDefaults> & Partial<ILoggerDefaults>); static tackOnRotatePeriodToBlobName({ blobName, rotatePeriod, }: Pick<IWinstonAzureBlob, "blobName" | "rotatePeriod">): string; static tackOnExtensionToBlobName({ blobName, extension, }: Pick<IWinstonAzureBlob, "blobName" | "extension">): string; static generateBlobName({ blobName, extension, rotatePeriod, }: Pick<IWinstonAzureBlob, "blobName" | "extension" | "rotatePeriod">): string; static createAzBlobClient(account_info: Account): BlobServiceClient; private static chunkString; private static isValidAccountOpts; private static appendBlobOperation; log(info: LogEntry, next: () => void): void; private push; private logToAppendBlob; } export declare const winstonAzureBlob: (opts: ConstructorParameters<typeof WinstonAzureBlob>[0]) => WinstonAzureBlob; export {}; //# sourceMappingURL=winston-azure-blob.d.ts.map