Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
"@aws-sdk/s3-request-presigner": "^3.956.0",
"@google/genai": "^1.40.0",
"@hayon/schemas": "workspace:*",
"@logtail/node": "^0.5.8",
"@logtail/winston": "^0.5.8",
"amqplib": "^0.10.9",
"axios": "^1.13.2",
"bcrypt": "^6.0.0",
Expand Down
1 change: 1 addition & 0 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const bootstrap = async () => {
expressInstance.use(passport.initialize());

expressInstance.get("/health", (req, res) => {
logger.info("Health check endpoint hit ✅");
new SuccessResponse("Server is running").send(res);
});

Expand Down
4 changes: 4 additions & 0 deletions backend/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,8 @@ export const ENV = {
PORT: Number(process.env.REDIS_PORT),
PASSWORD: process.env.REDIS_PASSWORD,
},

UPTIME: {
BETTER_STACK_TOKEN: required("BETTER_STACK_TOKEN"),
},
} as const;
13 changes: 10 additions & 3 deletions backend/src/utils/logger.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import winston from "winston";
import DailyRotateFile from "winston-daily-rotate-file";
import { Logtail } from "@logtail/node";
import { LogtailTransport } from "@logtail/winston";
import { ENV } from "../config/env";

const { combine, timestamp, printf, colorize, errors } = winston.format;

Expand All @@ -10,9 +13,9 @@ const logFormat = printf(({ level, message, timestamp, stack }) => {
const dailyRotateTransport = new DailyRotateFile({
filename: "logs/app-%DATE%.log",
datePattern: "YYYY-MM-DD",
zippedArchive: true, // compress old logs
maxSize: "20m", // rotate if file > 20MB
maxFiles: "14d", // keep logs for 14 days
zippedArchive: true,
maxSize: "20m",
maxFiles: "14d",
});

const errorRotateTransport = new DailyRotateFile({
Expand All @@ -24,6 +27,9 @@ const errorRotateTransport = new DailyRotateFile({
maxFiles: "30d",
});

// Better Stack
const logtail = new Logtail(ENV.UPTIME.BETTER_STACK_TOKEN);

const logger = winston.createLogger({
level: "info",
format: combine(timestamp({ format: "YYYY-MM-DD HH:mm:ss" }), errors({ stack: true }), logFormat),
Expand All @@ -33,6 +39,7 @@ const logger = winston.createLogger({
new winston.transports.Console({
format: combine(colorize(), logFormat),
}),
new LogtailTransport(logtail), // ← Better Stack added here
],
});

Expand Down
Loading