mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-21 09:26:00 +00:00
pino multistream - file logging
This commit is contained in:
@@ -2,7 +2,7 @@ const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const ageSeconds = 3600;
|
||||
|
||||
async function cleanDirectory(directory) {
|
||||
async function cleanDirectory(directory, age = undefined) {
|
||||
const files = await fs.readdir(directory);
|
||||
const now = new Date().getTime();
|
||||
|
||||
@@ -10,7 +10,7 @@ async function cleanDirectory(directory) {
|
||||
const full = path.join(directory, file);
|
||||
const stat = await fs.stat(full);
|
||||
const mtime = stat.mtime.getTime();
|
||||
const expirationTime = mtime + ageSeconds * 1000;
|
||||
const expirationTime = mtime + (age || ageSeconds) * 1000;
|
||||
if (now > expirationTime) {
|
||||
if (stat.isDirectory()) {
|
||||
await fs.rmdir(full, { recursive: true });
|
||||
|
||||
Reference in New Issue
Block a user