feat: add pino and pino-pretty for logging, implement logger utility

This commit is contained in:
Mauricio Siu 2025-05-26 01:45:14 -06:00
parent 7348526873
commit 9c73b8dc36
6 changed files with 41 additions and 0 deletions

View File

@ -36,6 +36,8 @@
"test": "vitest --config __test__/vitest.config.ts"
},
"dependencies": {
"pino": "9.4.0",
"pino-pretty": "11.2.2",
"@ai-sdk/anthropic": "^1.0.6",
"@ai-sdk/azure": "^1.0.15",
"@ai-sdk/cohere": "^1.0.6",

View File

@ -28,6 +28,8 @@
"typecheck": "tsc --noEmit"
},
"dependencies": {
"pino": "9.4.0",
"pino-pretty": "11.2.2",
"micromatch": "4.0.8",
"@ai-sdk/anthropic": "^1.0.6",
"@ai-sdk/azure": "^1.0.15",

View File

@ -131,3 +131,5 @@ export {
export * from "./utils/schedules/utils";
export * from "./utils/schedules/index";
export * from "./lib/logger";

View File

@ -0,0 +1,11 @@
import pino from "pino";
export const logger = pino({
transport: {
target: "pino-pretty",
options: {
colorize: true,
levelFirst: false,
},
},
});

View File

@ -8,6 +8,7 @@ import { runMySqlBackup } from "./mysql";
import { runPostgresBackup } from "./postgres";
import { runWebServerBackup } from "./web-server";
import { runComposeBackup } from "./compose";
import { logger } from "@dokploy/server/lib/logger";
export const scheduleBackup = (backup: BackupSchedule) => {
const {
@ -222,6 +223,17 @@ export const getBackupCommand = (
) => {
const containerSearch = getContainerSearchCommand(backup);
const backupCommand = generateBackupCommand(backup);
logger.info(
{
containerSearch,
backupCommand,
rcloneCommand,
logPath,
},
`Executing backup command: ${backup.databaseType} ${backup.backupType}`,
);
return `
set -eo pipefail;
echo "[$(date)] Starting backup process..." >> ${logPath};

View File

@ -364,6 +364,12 @@ importers:
otpauth:
specifier: ^9.2.3
version: 9.3.4
pino:
specifier: 9.4.0
version: 9.4.0
pino-pretty:
specifier: 11.2.2
version: 11.2.2
postgres:
specifier: 3.4.4
version: 3.4.4
@ -702,6 +708,12 @@ importers:
otpauth:
specifier: ^9.2.3
version: 9.3.4
pino:
specifier: 9.4.0
version: 9.4.0
pino-pretty:
specifier: 11.2.2
version: 11.2.2
postgres:
specifier: 3.4.4
version: 3.4.4