UNPKG

@mieweb/wikigdrive

Version:

Google Drive to MarkDown synchronization

90 lines 4.19 kB
import EventEmitter from 'node:events'; /** * FileStreamRotator: * * Returns a file stream that auto-rotates based on date. * * Options: * * - `filename` Filename including full path used by the stream * * - `frequency` How often to rotate. Options are 'daily', 'custom' and 'test'. 'test' rotates every minute. * If frequency is set to none of the above, a YYYYMMDD string will be added to the end of the filename. * * - `verbose` If set, it will log to STDOUT when it rotates files and name of log file. Default is TRUE. * * - `date_format` Format as used in moment.js http://momentjs.com/docs/#/displaying/format/. The result is used to replace * the '%DATE%' placeholder in the filename. * If using 'custom' frequency, it is used to trigger file change when the string representation changes. * * - `size` Max size of the file after which it will rotate. It can be combined with frequency or date format. * The size units are 'k', 'm' and 'g'. Units need to directly follow a number e.g. 1g, 100m, 20k. * * - `max_logs` Max number of logs to keep. If not set, it won't remove past logs. It uses its own log audit file * to keep track of the log files in a json format. It won't delete any file not contained in it. * It can be a number of files or number of days. If using days, add 'd' as the suffix. * * - `audit_file` Location to store the log audit file. If not set, it will be stored in the root of the application. * * - `end_stream` End stream (true) instead of the default behaviour of destroy (false). Set value to true if when writing to the * stream in a loop, if the application terminates or log rotates, data pending to be flushed might be lost. * * - `file_options` An object passed to the stream. This can be used to specify flags, encoding, and mode. * See https://nodejs.org/api/fs.html#fs_fs_createwritestream_path_options. Default `{ flags: 'a' }`. * * - `utc` Use UTC time for date in filename. Defaults to 'FALSE' * * - `extension` File extension to be appended to the filename. This is useful when using size restrictions as the rotation * adds a count (1,2,3,4,...) at the end of the filename when the required size is met. * * - `watch_log` Watch the current file being written to and recreate it in case of accidental deletion. Defaults to 'FALSE' * * - `create_symlink` Create a tailable symlink to the current active log file. Defaults to 'FALSE' * * - `symlink_name` Name to use when creating the symbolic link. Defaults to 'current.log' * * - `audit_hash_type` Use specified hashing algorithm for audit. Defaults to 'md5'. Use 'sha256' for FIPS compliance. * * To use with Express / Connect, use as below. * * const rotatingLogStream from 'FileStreamRotator').getStream({filename:"/tmp/test.log", frequency:"daily", verbose: false}) * app.use(express.logger({stream: rotatingLogStream, format: "default"})); * * @param {Object} options * @return {Object} * @api public */ export declare class FileStreamRotator extends EventEmitter { private readonly options; private readonly frequencyMetaData; private readonly verbose; private readonly fileSize; private readonly filename; private readonly dateFormat; private readonly file_options; private fileCount; private curSize; private curDate; private oldFile; private logfile; private rotateStream; private auditLog; constructor(options: any); end(...args: any[]): void; write(str: string, encoding?: BufferEncoding): void; addLogToAudit(newLog: any, verbose: any): void; setWriteStream(logfile: string): void; } /** * Returns frequency metadata * @param frequency * @returns {*} */ export declare function getFrequency(frequency: any): false | { type: any; digit: number; } | { type: any; digit: undefined; } | undefined; //# sourceMappingURL=FileStreamRotator.d.ts.map