From 32aa48e94682e74661b11fa60df6b8174f7555c4 Mon Sep 17 00:00:00 2001 From: derekjqwang Date: Mon, 15 Jun 2020 20:09:11 +0800 Subject: [PATCH 1/3] docs(cn): translate src/content/api/logging.md --- src/content/api/logging.md | 62 +++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/content/api/logging.md b/src/content/api/logging.md index c1b6f57060da..3681995b570c 100644 --- a/src/content/api/logging.md +++ b/src/content/api/logging.md @@ -1,53 +1,53 @@ --- -title: Logger Interface +title: Logger API sort: 6 contributors: - EugeneHlushko - wizardofhogwarts --- -T> Available since webpack 4.39.0 +T> 本 API 从 v4.39.0 开始可用 -Logging output is an additional way to display messages to the end users. +使用 Logger 输出消息是一种向用户展示信息的有效方式。 -webpack logger is available to [loaders](/loaders/) and [plugins](/api/plugins/#logging). Emitting as part of the [Stats](/api/stats/) and configured by the user in [webpack configuration](/configuration/). +Webpack Logger 可以用在 [loaders](/loaders/) 和 [plugins](/api/plugins/#logging)。生成的 Logger 将作为 [统计信息](/api/stats/) 的一部分进行输出,并且用户可以使用 [webpack configuration](/configuration/) 对 Logger 进行配置。 -Benefits of custom logging API in webpack: +在 Webpack 中使用自定义 Logger API 的优点: -- Common place to [configure the logging](/configuration/stats/#statslogging) display level -- Logging output exportable as part of the `stats.json` -- Stats presets affect logging output -- Plugins can affect logging capturing and display level -- When using multiple plugins and loaders they use a common logging solution -- CLI, UI tools for webpack may choose different ways to display logging -- webpack core can emit logging output, e.g. timing data +- 可以 [配置](/configuration/stats/#statslogging) 日志的显示级别 +- Logging 记录可作为 `stats.json` 的一部分输出 +- 统计预设可以设置 Logging 的输出 +- plugins 可以设置 Logging 的捕获与显示级别 +- 当使用多个 plugins 和 loaders 时,提供更加通用的日志记录解决方案 +- 基于 Webpack 开发的 CLI、UI 工具等可能会选择不同的方式来显示 Logging +- Webpack 核心可以生成日志进行输出,例如:timing data -By introducing webpack logging API we hope to unify the way webpack plugins and loaders emit logs and allow better ways to inspect build problems. Integrated logging solution supports plugins and loaders developers by improving their development experience. Paves the way for non-CLI webpack solutions like dashboards or other UIs. +通过引入 Webpack Logger API,我们希望统一 Webpack plugins 和 loaders 生成日志的方式,并提供更好的方法来检查构建问题。 集成的 Logging 解决方案可以帮助 plugins 和 loader 的开发人员提升他们的开发经验。同时为非 CLI 形式的 Webpack 解决方案构建铺平了道路,例如 dashboard 或其他 UI。 -W> __Avoid noise in the log!__ Keep in mind that multiple plugins and loaders are used together. Loaders are usually processing multiple files and are invoked for every file. Choose a logging level as low as possible to keep the log output informative. +W> __避免在日志中输出无效信息!__请记住,多个 plugins 和 loader 经常一起使用。Loader 通常处理多个文件,并且每个文件都会调用,所以选择一个尽可能低的 logging 级别以保证 log 的信息量。 ## Logger methods -- `logger.error(...)`: for error messages -- `logger.warn(...)`: for warnings -- `logger.info(...)`: for __important__ information messages. These messages are displayed by default. Only use this for messages that the user really needs to see -- `logger.log(...)`: for __unimportant__ information messages. These messages are displayed only when user had opted-in to see them -- `logger.debug(...)`: for debugging information. These messages are displayed only when user had opted-in to see debug logging for specific modules -- `logger.trace()`: to display a stack trace. Displayed like `logger.debug` -- `logger.group(...)`: to group messages. Displayed collapsed like `logger.log` -- `logger.groupEnd()`: to end a logging group -- `logger.groupCollapsed(...)`: to group messages together. Displayed collapsed like `logger.log`. Displayed expanded when logging level is set to `'verbose'` or `'debug'`. -- `logger.status`: writes a temporary message, setting a new status, overrides the previous one -- `logger.clear()`: to print a horizontal line. Displayed like `logger.log` -- `logger.profile(...)`, `logger.profileEnd(...)`: to capture a profile. Delegated to `console.profile` when supported +- `logger.error(...)`:用于输出错误信息 +- `logger.warn(...)`:用于输出警告信息 +- `logger.info(...)`:用于输出__重要__信息。默认情况下会显示这些信息,所以仅用于输出用户真正需要查看的消息 +- `logger.log(...)`:用于输出__不重要__的信息。只有当用户选择查看时,才会显示 +- `logger.debug(...)`:用于输出调试信息。只有当用户选择查看特定模块的调试日志时,才会显示 +- `logger.trace()`:显示堆栈跟踪信息,展示形式类似于 `logger.debug` +- `logger.group(...)`:将消息进行分组,展示形式类似于 `logger.log` +- `logger.groupEnd()`:结束消息分组 +- `logger.groupCollapsed(...)`:将消息进行分组。默认显示为折叠 `logger.log` 日志,当日志记录级别设置为 `'verbose'` 或 `'debug'` 时,显示展开的日志 +- `logger.status`:写入一条临时消息,并且设置新状态,覆盖上一个状态 +- `logger.clear()`:打印水平线。展示形式类似于 `logger.log` +- `logger.profile(...)`,`logger.profileEnd(...)`:捕获配置文件。当支持 `console.profile` API 时,使用其进行输出 ## Runtime Logger API -Runtime logger API is only intended to be used as a development tool, it is not intended to be included in [production mode](/configuration/mode/#mode-production). +Runtime logger API 仅应该用作开发工具,不应该包含在 [生产模式](/configuration/mode/#mode-production)中。 -- `const logging = require('webpack/lib/logging/runtime')`: to use the logger in runtime, require it directly from webpack -- `logging.getLogger('name')`: to get individual logger by name -- `logging.configureDefaultLogger(...)`: to override the default logger. +- `const logging = require('webpack/lib/logging/runtime')`:直接从 Webpack 中引入即可使用 logger API +- `logging.getLogger('name')`:根据名称获取一个 logger 的实例 +- `logging.configureDefaultLogger(...)`:重写 logger 的默认配置 ```javascript const logging = require('webpack/lib/logging/runtime'); @@ -57,4 +57,4 @@ logging.configureDefaultLogger({ }); ``` -- `logging.hooks.log`: to apply Plugins to the runtime logger +- `logging.hooks.log`:向 logger 中添加 Plugins From a2d845a99cc5b879302deb1d448f0b2900ba5479 Mon Sep 17 00:00:00 2001 From: derekjqwang Date: Thu, 18 Jun 2020 18:43:44 +0800 Subject: [PATCH 2/3] docs(cn): translate src/content/api/logging.md --- src/content/api/logging.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/content/api/logging.md b/src/content/api/logging.md index 3681995b570c..98162dc606e1 100644 --- a/src/content/api/logging.md +++ b/src/content/api/logging.md @@ -1,5 +1,5 @@ --- -title: Logger API +title: Logger 接口 sort: 6 contributors: - EugeneHlushko @@ -10,21 +10,21 @@ T> 本 API 从 v4.39.0 开始可用 使用 Logger 输出消息是一种向用户展示信息的有效方式。 -Webpack Logger 可以用在 [loaders](/loaders/) 和 [plugins](/api/plugins/#logging)。生成的 Logger 将作为 [统计信息](/api/stats/) 的一部分进行输出,并且用户可以使用 [webpack configuration](/configuration/) 对 Logger 进行配置。 +Webpack Logger 可以用在 [loaders](/loaders/) 和 [plugins](/api/plugins/#logging)。生成的 Logger 将作为 [统计信息](/api/stats/) 的一部分进行输出,并且用户可以在 [webpack 配置文件](/configuration/) 中对 Logger 进行配置。 在 Webpack 中使用自定义 Logger API 的优点: -- 可以 [配置](/configuration/stats/#statslogging) 日志的显示级别 -- Logging 记录可作为 `stats.json` 的一部分输出 -- 统计预设可以设置 Logging 的输出 -- plugins 可以设置 Logging 的捕获与显示级别 +- 可以 [配置](/configuration/stats/#statslogging) 日志的展示级别 +- 日志内容可作为 `stats.json` 的一部分输出 +- 统计预设会影响日志的输出 +- 使用 plugins 可以影响日志的捕获与展示级别 - 当使用多个 plugins 和 loaders 时,提供更加通用的日志记录解决方案 -- 基于 Webpack 开发的 CLI、UI 工具等可能会选择不同的方式来显示 Logging -- Webpack 核心可以生成日志进行输出,例如:timing data +- 基于 Webpack 开发的 CLI、UI 工具等可能会选择不同的方式来展示日志 +- Webpack 核心可以触发日志输出,例如:timing data 通过引入 Webpack Logger API,我们希望统一 Webpack plugins 和 loaders 生成日志的方式,并提供更好的方法来检查构建问题。 集成的 Logging 解决方案可以帮助 plugins 和 loader 的开发人员提升他们的开发经验。同时为非 CLI 形式的 Webpack 解决方案构建铺平了道路,例如 dashboard 或其他 UI。 -W> __避免在日志中输出无效信息!__请记住,多个 plugins 和 loader 经常一起使用。Loader 通常处理多个文件,并且每个文件都会调用,所以选择一个尽可能低的 logging 级别以保证 log 的信息量。 +W> __避免在日志中输出无效信息!__请记住,多个 plugin 和 loader 经常一起使用。loader 通常处理多个文件,并且每个文件都会调用,所以尽可能选择较低的日志级别以保证 log 的信息量。 ## Logger methods From 752329df7820d313bc5f89afd0e89e48d1ccc346 Mon Sep 17 00:00:00 2001 From: derekjqwang Date: Thu, 18 Jun 2020 18:45:49 +0800 Subject: [PATCH 3/3] docs(cn): translate src/content/api/logging.md --- src/content/api/logging.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/content/api/logging.md b/src/content/api/logging.md index 98162dc606e1..b46f5febed89 100644 --- a/src/content/api/logging.md +++ b/src/content/api/logging.md @@ -10,15 +10,15 @@ T> 本 API 从 v4.39.0 开始可用 使用 Logger 输出消息是一种向用户展示信息的有效方式。 -Webpack Logger 可以用在 [loaders](/loaders/) 和 [plugins](/api/plugins/#logging)。生成的 Logger 将作为 [统计信息](/api/stats/) 的一部分进行输出,并且用户可以在 [webpack 配置文件](/configuration/) 中对 Logger 进行配置。 +Webpack Logger 可以用在 [loader](/loaders/) 和 [plugin](/api/plugins/#logging)。生成的 Logger 将作为 [统计信息](/api/stats/) 的一部分进行输出,并且用户可以在 [webpack 配置文件](/configuration/) 中对 Logger 进行配置。 在 Webpack 中使用自定义 Logger API 的优点: - 可以 [配置](/configuration/stats/#statslogging) 日志的展示级别 - 日志内容可作为 `stats.json` 的一部分输出 - 统计预设会影响日志的输出 -- 使用 plugins 可以影响日志的捕获与展示级别 -- 当使用多个 plugins 和 loaders 时,提供更加通用的日志记录解决方案 +- 使用 plugin 可以影响日志的捕获与展示级别 +- 当使用多个 plugin 和 loader 时,提供更加通用的日志记录解决方案 - 基于 Webpack 开发的 CLI、UI 工具等可能会选择不同的方式来展示日志 - Webpack 核心可以触发日志输出,例如:timing data