mirror of
https://github.com/LukeHagar/dokploy.git
synced 2025-12-06 04:19:37 +00:00
feat: add pino and pino-pretty for logging, implement logger utility
This commit is contained in:
@@ -36,6 +36,8 @@
|
|||||||
"test": "vitest --config __test__/vitest.config.ts"
|
"test": "vitest --config __test__/vitest.config.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"pino": "9.4.0",
|
||||||
|
"pino-pretty": "11.2.2",
|
||||||
"@ai-sdk/anthropic": "^1.0.6",
|
"@ai-sdk/anthropic": "^1.0.6",
|
||||||
"@ai-sdk/azure": "^1.0.15",
|
"@ai-sdk/azure": "^1.0.15",
|
||||||
"@ai-sdk/cohere": "^1.0.6",
|
"@ai-sdk/cohere": "^1.0.6",
|
||||||
|
|||||||
@@ -28,6 +28,8 @@
|
|||||||
"typecheck": "tsc --noEmit"
|
"typecheck": "tsc --noEmit"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"pino": "9.4.0",
|
||||||
|
"pino-pretty": "11.2.2",
|
||||||
"micromatch": "4.0.8",
|
"micromatch": "4.0.8",
|
||||||
"@ai-sdk/anthropic": "^1.0.6",
|
"@ai-sdk/anthropic": "^1.0.6",
|
||||||
"@ai-sdk/azure": "^1.0.15",
|
"@ai-sdk/azure": "^1.0.15",
|
||||||
|
|||||||
@@ -131,3 +131,5 @@ export {
|
|||||||
|
|
||||||
export * from "./utils/schedules/utils";
|
export * from "./utils/schedules/utils";
|
||||||
export * from "./utils/schedules/index";
|
export * from "./utils/schedules/index";
|
||||||
|
|
||||||
|
export * from "./lib/logger";
|
||||||
|
|||||||
11
packages/server/src/lib/logger.ts
Normal file
11
packages/server/src/lib/logger.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import pino from "pino";
|
||||||
|
|
||||||
|
export const logger = pino({
|
||||||
|
transport: {
|
||||||
|
target: "pino-pretty",
|
||||||
|
options: {
|
||||||
|
colorize: true,
|
||||||
|
levelFirst: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -8,6 +8,7 @@ import { runMySqlBackup } from "./mysql";
|
|||||||
import { runPostgresBackup } from "./postgres";
|
import { runPostgresBackup } from "./postgres";
|
||||||
import { runWebServerBackup } from "./web-server";
|
import { runWebServerBackup } from "./web-server";
|
||||||
import { runComposeBackup } from "./compose";
|
import { runComposeBackup } from "./compose";
|
||||||
|
import { logger } from "@dokploy/server/lib/logger";
|
||||||
|
|
||||||
export const scheduleBackup = (backup: BackupSchedule) => {
|
export const scheduleBackup = (backup: BackupSchedule) => {
|
||||||
const {
|
const {
|
||||||
@@ -222,6 +223,17 @@ export const getBackupCommand = (
|
|||||||
) => {
|
) => {
|
||||||
const containerSearch = getContainerSearchCommand(backup);
|
const containerSearch = getContainerSearchCommand(backup);
|
||||||
const backupCommand = generateBackupCommand(backup);
|
const backupCommand = generateBackupCommand(backup);
|
||||||
|
|
||||||
|
logger.info(
|
||||||
|
{
|
||||||
|
containerSearch,
|
||||||
|
backupCommand,
|
||||||
|
rcloneCommand,
|
||||||
|
logPath,
|
||||||
|
},
|
||||||
|
`Executing backup command: ${backup.databaseType} ${backup.backupType}`,
|
||||||
|
);
|
||||||
|
|
||||||
return `
|
return `
|
||||||
set -eo pipefail;
|
set -eo pipefail;
|
||||||
echo "[$(date)] Starting backup process..." >> ${logPath};
|
echo "[$(date)] Starting backup process..." >> ${logPath};
|
||||||
|
|||||||
12
pnpm-lock.yaml
generated
12
pnpm-lock.yaml
generated
@@ -364,6 +364,12 @@ importers:
|
|||||||
otpauth:
|
otpauth:
|
||||||
specifier: ^9.2.3
|
specifier: ^9.2.3
|
||||||
version: 9.3.4
|
version: 9.3.4
|
||||||
|
pino:
|
||||||
|
specifier: 9.4.0
|
||||||
|
version: 9.4.0
|
||||||
|
pino-pretty:
|
||||||
|
specifier: 11.2.2
|
||||||
|
version: 11.2.2
|
||||||
postgres:
|
postgres:
|
||||||
specifier: 3.4.4
|
specifier: 3.4.4
|
||||||
version: 3.4.4
|
version: 3.4.4
|
||||||
@@ -702,6 +708,12 @@ importers:
|
|||||||
otpauth:
|
otpauth:
|
||||||
specifier: ^9.2.3
|
specifier: ^9.2.3
|
||||||
version: 9.3.4
|
version: 9.3.4
|
||||||
|
pino:
|
||||||
|
specifier: 9.4.0
|
||||||
|
version: 9.4.0
|
||||||
|
pino-pretty:
|
||||||
|
specifier: 11.2.2
|
||||||
|
version: 11.2.2
|
||||||
postgres:
|
postgres:
|
||||||
specifier: 3.4.4
|
specifier: 3.4.4
|
||||||
version: 3.4.4
|
version: 3.4.4
|
||||||
|
|||||||
Reference in New Issue
Block a user