Skip to content

Commit 4a1e9c6

Browse files
authored
Merge pull request #4 from FOSWLY/dev
v2.0.1
2 parents 3a84a36 + 6532822 commit 4a1e9c6

File tree

8 files changed

+21
-10
lines changed

8 files changed

+21
-10
lines changed

.example.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
SERVICE_PORT=3312
2-
USE_WORKER="false"
2+
USE_WORKER=false
3+
LOG_TO_FILE=false
34
API_TOKEN="" # For get sharing url
45
# SESSION_ID_COOKIE="XXXX" # If lib YaHMAC is invalid you can set your cookies and summarize articles/text (video requires valid YaHMAC)

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ COPY src src
77
RUN bun install
88

99
ENV SERVICE_PORT=3312
10+
ENV LOG_TO_FILE=false
1011
# ENV USE_WORKER="true"
1112
# ENV WORKER_HOST="http://127.0.0.1:7674/browser"
1213
# ENV WORKER_HOST_TH="http://127.0.0.1:7674/th"

changelog.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 2.0.1
2+
3+
- Добавлено управление логированием в файл с помощью переменной окружения LOG_TO_FILE (по умолчанию отключено)
4+
15
# 2.0.0
26

37
> [!CAUTION]

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "summarize-backend",
3-
"version": "2.0.0",
3+
"version": "2.0.1",
44
"author": "Toil",
55
"repository": {
66
"type": "git",

src/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export default Value.Parse(ConfigSchema, {
2323
logging: {
2424
level: Bun.env.NODE_ENV === "production" ? "info" : "debug",
2525
logPath: path.join(__dirname, "..", "logs"),
26+
logToFile: Bun.env.LOG_TO_FILE === "true",
2627
loki: {
2728
host: Bun.env.LOKI_HOST,
2829
user: Bun.env.LOKI_USER,

src/logging.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { pino, type TransportMultiOptions, type TransportTargetOptions } from "p
33

44
import config from "@/config";
55

6-
const { loki } = config.logging;
6+
const { loki, logToFile } = config.logging;
77
const startingDate = new Date().toISOString().split("T")[0];
88

99
type PinoOpts = Parameters<typeof pino>[0] & {
@@ -33,13 +33,15 @@ opts.transport.targets.push({
3333
},
3434
});
3535

36-
opts.transport.targets.push({
37-
level: config.logging.level,
38-
target: "pino/file",
39-
options: {
40-
destination: path.join(config.logging.logPath, `${startingDate}.log`),
41-
},
42-
});
36+
if (logToFile) {
37+
opts.transport.targets.push({
38+
level: config.logging.level,
39+
target: "pino/file",
40+
options: {
41+
destination: path.join(config.logging.logPath, `${startingDate}.log`),
42+
},
43+
});
44+
}
4345

4446
if (loki.host) {
4547
opts.transport.targets.push({

src/schemas/config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export const ConfigSchema = t.Object({
4747
logging: t.Object({
4848
level: LoggingLevel,
4949
logPath: t.String(),
50+
logToFile: t.Boolean({ default: false }),
5051
loki: t.Object({
5152
host: t.String({ default: "" }),
5253
user: t.String({ default: "" }),

src/types/global.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ declare module "bun" {
55
APP_NAME: string;
66
APP_DESC: string;
77
APP_CONTACT_EMAIL: string;
8+
LOG_TO_FILE: string;
89
LOKI_HOST: string;
910
LOKI_USER: string;
1011
LOKI_PASSWORD: string;

0 commit comments

Comments
 (0)