mb-rrvideo-server 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,10 +30,10 @@ services:
30
30
  deploy:
31
31
  resources:
32
32
  limits:
33
- cpus: '4'
33
+ # cpus: '12'
34
34
  memory: 4G
35
35
  reservations:
36
- cpus: '2'
36
+ cpus: '4'
37
37
  memory: 2G
38
38
 
39
39
  healthcheck:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mb-rrvideo-server",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "视频转码服务 - 接收可回溯机请求,执行转码/合并,上传MinIO/本地存储",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/logger.js CHANGED
@@ -1,11 +1,19 @@
1
1
  const fs = require('fs');
2
2
  const path = require('path');
3
+ const config = require('./config');
4
+
5
+ const LOG_LEVELS = {
6
+ 'DEBUG': 0,
7
+ 'INFO': 1,
8
+ 'WARN': 2,
9
+ 'ERROR': 3
10
+ };
3
11
 
4
12
  class Logger {
5
13
  constructor() {
6
14
  this.buffers = new Map(); // fileKey -> { logs: [], timer: null }
7
- this.flushInterval = 2000; // 2秒
8
- this.bufferMaxSize = 500; // 500条
15
+ this.flushInterval = config.get('log.flush_interval', 2000); // 默认2秒
16
+ this.bufferMaxSize = config.get('log.buffer_max_size', 500); // 默认500条
9
17
  this.baseDir = path.join(__dirname, '../logs');
10
18
  }
11
19
 
@@ -70,6 +78,15 @@ class Logger {
70
78
 
71
79
  log(logType, fileName, message, level = 'INFO') {
72
80
  try {
81
+ // 检查日志级别
82
+ const currentLevelStr = config.get('log.level', 'INFO').toUpperCase();
83
+ const currentLevel = LOG_LEVELS[currentLevelStr] !== undefined ? LOG_LEVELS[currentLevelStr] : LOG_LEVELS['INFO'];
84
+ const msgLevel = LOG_LEVELS[level.toUpperCase()] !== undefined ? LOG_LEVELS[level.toUpperCase()] : LOG_LEVELS['INFO'];
85
+
86
+ if (msgLevel < currentLevel) {
87
+ return;
88
+ }
89
+
73
90
  const timestamp = this.getCurrentTime();
74
91
  const lines = String(message).split('\n');
75
92
  const fileKey = `${logType}::${fileName}`;