This commit is contained in:
DCCONSTRUCTIONS
2026-04-18 18:39:25 +03:00
commit 3ba092b60c
4944 changed files with 497564 additions and 0 deletions
+10
View File
@@ -0,0 +1,10 @@
.next/
.react-router/
.turbo/
.vite/
build/
dist/
node_modules/
out/
pnpm-lock.yaml
storybook-static/
+70
View File
@@ -0,0 +1,70 @@
# Logger Package
This package provides a logger and a request logger utility built using [Winston](https://github.com/winstonjs/winston). It offers customizable log levels using env and supports structured logging for general application logs and HTTP requests.
## Features.
- Dynamic log level configuration using env.
- Pre-configured winston logger for general usage (`logger`).
- Request logger middleware that logs incoming request
## Usage
### Adding as a package
Add this package as a dependency in package.json
```typescript
dependency: {
...
@plane/logger":"*",
...
}
```
### Importing the Logger
```typescript
import { logger, requestLogger } from "@plane/logger";
```
### Usage
### `logger`: General Logger
Use this for general application logs.
```typescript
logger.info("This is an info log");
logger.warn("This is a warning");
logger.error("This is an error");
```
### `requestLogger`: Request Logger Middleware
Use this as a middleware for incoming requests
```typescript
const app = express();
app.use(requestLogger);
```
## Available Log Levels
- `error`
- `warn`
- `info` (default)
- `http`
- `verbose`
- `debug`
- `silly`
## Log file
- Log files are stored in logs folder of current working directory. Error logs are stored in files with format `error-%DATE%.log` and combined logs are stored with format `combined-%DATE%.log`.
- Log files have a 7 day rotation period defined.
## Configuration
- By default, the log level is set to `info`.
- You can specify a log level by adding a LOG_LEVEL in .env.
+40
View File
@@ -0,0 +1,40 @@
{
"name": "@plane/logger",
"version": "1.3.0",
"private": true,
"description": "Logger shared across multiple apps internally",
"license": "AGPL-3.0",
"type": "module",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.mts",
"exports": {
".": "./dist/index.mjs",
"./package.json": "./package.json"
},
"scripts": {
"build": "tsdown",
"dev": "tsdown --watch --no-clean",
"check:lint": "oxlint --max-warnings=0 .",
"check:types": "tsc --noEmit",
"check:format": "oxfmt --check .",
"fix:lint": "oxlint --fix .",
"fix:format": "oxfmt .",
"clean": "rm -rf .turbo && rm -rf .next && rm -rf node_modules && rm -rf dist"
},
"dependencies": {
"express-winston": "^4.2.0",
"winston": "^3.17.0"
},
"devDependencies": {
"@plane/typescript-config": "workspace:*",
"@types/express": "4.17.23",
"@types/node": "catalog:",
"tsdown": "catalog:",
"typescript": "catalog:"
},
"inlinedDependencies": {
"@types/express": "4.17.23",
"@types/express-serve-static-core": "4.19.6"
}
}
+21
View File
@@ -0,0 +1,21 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import type { LoggerOptions } from "winston";
import { createLogger, format, transports } from "winston";
export const loggerConfig: LoggerOptions = {
level: process.env.LOG_LEVEL || "info",
format: format.combine(
format.timestamp({
format: "YYYY-MM-DD HH:mm:ss:ms",
}),
format.json()
),
transports: [new transports.Console()],
};
export const logger = createLogger(loggerConfig);
+8
View File
@@ -0,0 +1,8 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
export * from "./config";
export * from "./middleware";
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2023-present Plane Software, Inc. and contributors
* SPDX-License-Identifier: AGPL-3.0-only
* See the LICENSE file for details.
*/
import type { RequestHandler } from "express";
import expressWinston from "express-winston";
import { transports } from "winston";
import { loggerConfig } from "./config";
export const loggerMiddleware: RequestHandler = expressWinston.logger({
...loggerConfig,
transports: [new transports.Console()],
msg: "{{req.method}} {{req.url}} {{res.statusCode}} {{res.responseTime}}ms",
expressFormat: true,
});
+11
View File
@@ -0,0 +1,11 @@
{
"extends": "@plane/typescript-config/node-library.json",
"compilerOptions": {
"paths": {
"@/*": ["./src/*"]
},
"experimentalDecorators": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
@@ -0,0 +1,8 @@
import { defineConfig } from "tsdown";
export default defineConfig({
entry: ["src/index.ts"],
format: ["esm"],
dts: true,
exports: true,
});