@dreamit/otel-json-logger

中文文档
3.0.3发布于 2025/07/10MITTypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 2258

JSON 诊断打开远程测量的日志

此软件包已被标记为弃用

@dreamit/otel-json-logger is deprecated and will no longer be maintained. Use at your own risk!

中文使用文档
文档目录12 节
  1. 安装
  2. 兼容性
  3. 特征
  4. 使用量
  5. JsonDiagLogger 函数
  6. 一般职能
  7. DiagLogger 接口功能
  8. 日志级值
  9. 更改日志
  10. ưμ㼯a
  11. 联系人
  12. 许可证

奥特尔-杰森-洛格

JSON 诊断打开远程测量的日志

折旧:此图书馆将不再维持. 冒着自己的风险使用!

安装

npm install --save @dreamit/otel-json-logger

项目内提供类型脚本申报.

兼容性

奥特尔-杰森-洛格 与 @ opletetmeterm/ api (打开的距离) ^ 1. 6.0 版本.

特征

  • 为 OpenTeleometry 提供 JSON 记录器 对话框 接口
  • 用对象和阵列以及日志参数来字符串/检查信件,以避免破坏记录工具
  • 为日志条目创建 ISODate 时间戳

使用量

创建一个 杰森·迪亚格-洛克 通过提供匹配对象 日志器Name 财务报告和审定财务报表 服务Name。可以独立地使用记录器对 JSON 进行控制控制 全球 对话框。 。 。 .

import { JsonDiagLogger } from '@dreamit/otel-json-logger'
import { diag, DiagLogLevel } from "@opentelemetry/api";

// Standalone
const logger = new JsonDiagLogger({
    loggerName: 'test-logger', // The loggerName printed in field "logger"
    serviceName: 'test-service', // The serviceName printed in field "serviceName"
    minLogLevel: 'INFO', // Optional: The minimum log level to use. Default: Does not check for min LogLevel.
    logFirstIncomingRequest: true, // Optional: If true, the first incoming request will be logged. Other messages on debug level will be log if minLogLevel is set to debug or higher. Default: false. Note: If you use diag.setLogger ensure that at least "DEBUG" is set, otherwise the message will be ignored.
    logLevelForAsyncAttributeError: 'INFO' // Optional: The log level to use for the message "Accessing resource attributes before async attributes settled". These errors might not be relevant enough to log them on error level.
    logLevelForRegisterGlobalMessages: 'INFO' // Optional: The log level to use for messages "... Registered a global ...". These are helpful to check if OTEL is running properly but are logged on debug level by default. Increase this log level to see these messages.
    logLevelForServiceRequestErrorMessages: 'INFO', // Optional: The log level to use for error message "Service request". These contain request information that might not be logged on error level.
    logLevelForTimeoutErrorMessages: 'INFO', // Optional: The log level to use for Timeout related messages. These might be of short nature and be downgraded or ignored.
    logLevelForVerbose: 'OFF' // Optional: Set LogLevel for verbose entries or ignore them
    truncateLimit: 200 // Optional:  The length of the message before the message gets truncated. Default: undefined/0 (off).
    truncatedText: '_TRC_' // Optional: The text to display if a message is truncated.
})
logger.debug('test', 1, {name: 'myname'})

// Add as global DiagLogger
diag.setLogger(logger, DiagLogLevel.ERROR)

JsonDiagLogger 函数

一般职能

  • 创建日志 Entry: 创建并返回类型日志条目 日志条目 提供了有关资料.
  • 负数: 由所有人调用的中心功能 对话框 接口功能。 电话 创建日志 Entry,字符串结果和呼叫 控制台.log ()。 。 。 .
  • 格式: 格式化信件。 如果信件中包含一个对象或阵列,将其包裹在JSON.stringify中以避免这些被解释为JSON对象.
  • 设置选项: 设置 锁定选项 用于伐木。 可以在构建器调用后调用设置新/ 其他选项 .
  • 包含超时:检查信件是否包含"4 DEADLINE EXED"或"14 UNAVAILALA"等超时信息.
  • 正在请求日志:检查这些参数是否属于来函请求信件的一部分,即第一个参数包含"来函请求"的文本
  • 是等效或更高的明洛格级:检查日志级别是否等于或高于最小日志级别.
  • 包含 Async 属性错误: 检查信件中是否包含像"在Async属性确定前访问资源属性"这样的async属性错误.

DiagLogger 接口功能

  • 调试: 记录调试消息
  • 错误: 记录错误消息
  • 资讯: 记录信息消息
  • 动词: 记录动词消息
  • 警告( e): 记录警告消息

日志级值

  • 吉布提
  • 错误
  • 信息通报
  • 关闭 : 不要登录这些条目 !
  • 韦尔布斯
  • 战争

更改日志

ưμ㼯a

日志级别 已经从 enum 类型改为字符串类型.

联系人

如果你有问题,请访问我们 问题页 如果还没有适合你议题的问题,就打开一个新问题.

许可证

奥特尔 -杰森 -洛格下方 麻省理工学院。 。 。 .

版本与发布记录

@dreamit/otel-json-logger 共发布 21 个版本,首次发布于 2023/09/21;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.0.3latest2025/07/101.3 年前
3.0.22025/06/061.4 年前
3.0.12025/04/161.6 年前
3.0.02025/03/181.7 年前
2.7.32024/12/101.9 年前
2.7.22024/11/152 年前

关于 @dreamit/otel-json-logger 的常见问题

@dreamit/otel-json-logger 是什么?

JSON 诊断打开远程测量的日志注意:该包已被作者标记为弃用——@dreamit/otel-json-logger is deprecated and will no longer be maintained. Use at your own risk!

如何安装 @dreamit/otel-json-logger?

在项目目录运行 npm install @dreamit/otel-json-logger,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@opentelemetry/api(^1.6.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@dreamit/otel-json-logger 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dreamit/otel-json-logger 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@dreamit/otel-json-logger 可以商用吗?

@dreamit/otel-json-logger 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dreamit/otel-json-logger 的下载量有多少?

根据 npm 官方下载统计,@dreamit/otel-json-logger 在 2026/10/13 – 2026/11/11 这 30 天内被下载 2,258 次,日均约 75 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dreamit/otel-json-logger 还在维护吗?

最新版本 3.0.3 发布于 2025/07/10(1.3 年前);至今共发布 21 个版本,其中过去 12 个月发布了 0 个;首次发布于 2023/09/21。作者已将其标记为弃用,新项目建议寻找替代方案。