linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Wu X.C." <bobwxc@email.cn>
To: Yanteng Si <siyanteng@loongson.cn>
Cc: corbet@lwn.net, alexs@kernel.org, chenhuacai@kernel.org,
	jiaxun.yang@flygoat.com, linux-doc@vger.kernel.org,
	realpuyuwang@gmail.com, siyanteng01@gmail.com
Subject: Re: [PATCH 2/3] docs/zh_CN: add core-api printk-basics.rst translation
Date: Tue, 20 Apr 2021 00:19:17 +0800	[thread overview]
Message-ID: <20210419161916.GA8987@bobwxc.top> (raw)
In-Reply-To: <00c5a51380b32c894f7851015d079c1e2a5e9220.1618836460.git.siyanteng@loongson.cn>

On Mon, Apr 19, 2021 at 09:10:56PM +0800, Yanteng Si wrote:
> This patch translates Documentation/core-api/printk-basics.rst into Chinese.
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
>  .../zh_CN/core-api/printk-basics.rst          | 118 ++++++++++++++++++
>  1 file changed, 118 insertions(+)
>  create mode 100644 Documentation/translations/zh_CN/core-api/printk-basics.rst
> 
> diff --git a/Documentation/translations/zh_CN/core-api/printk-basics.rst b/Documentation/translations/zh_CN/core-api/printk-basics.rst
> new file mode 100644
> index 000000000000..056ca88604b2
> --- /dev/null
> +++ b/Documentation/translations/zh_CN/core-api/printk-basics.rst
> @@ -0,0 +1,118 @@
> +.. SPDX-License-Identifier: GPL-2.0
> +.. include:: ../disclaimer-zh_CN.rst
> +
> +:Original: :doc:`../../../core-api/printk-basics`

As Cerbot suggested, better to use 
:Original: Documentation/core-api/printk-basics.rst

> +:Translator: Yanteng Si <siyanteng@loongson.cn>
> +
> +.. _cn_printk-basics.rst:
> +
> +
> +==================
> +使用printk记录信息
> +==================

建议仔细推敲本文所有 message 翻译
信息 or 消息
不一定要统一
消息 for one sentence, short information
信息 for a long, whole information

> +
> +printk()是Linux内核中最广为人知的函数之一。它是我们打印信息的标准工具,通常也是追踪和调试
> +的最基本方法。如果你熟悉printf(3),你就能够知道printk()是基于它的,尽管它在功能上有一些不
> +同之处。:

remove 。

> +
> +  - printk() 信息可以指定日志级别。
> +
> +  - 格式字符串虽然与C99基本兼容,但并不遵循完全相同的规范。它有一些扩展和一些限制(没
> +    有 ``%n`` 或浮点转换指定符)。参见:ref: `如何正确地获得printk格式指定符<printk-specifiers>` 。
> +

wrong indent next paragraph

> +    所有的printk()消息都会被打印到内核日志缓冲区,这是一个通过/dev/kmsg输出到用户空间的环
> +    形缓冲区。读取它的通常方法是使用 ``dmesg`` 。
> +
> +printk()的用法通常是这样的
> +
> +::

Please make a test when "::" after texts and at the begin of a line.
Do you find the ':' ?

> +
> +  printk(KERN_INFO "Message: %s\n", arg);
> +
> +其中 ``KERN_INFO`` 是日志级别(注意,它与格式字符串连在一起,日志级别不是一个单独的参数)。
> +可用的日志级别是:
> +
> +
> ++----------------+--------+-----------------------------------------------+
> +| 名称           | 字符串 |  别名函数                                     |
> ++================+========+===============================================+
> +| KERN_EMERG     | "0"    | pr_emerg()                                    |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_ALERT     | "1"    | pr_alert()                                    |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_CRIT      | "2"    | pr_crit()                                     |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_ERR       | "3"    | pr_err()                                      |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_WARNING   | "4"    | pr_warn()                                     |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_NOTICE    | "5"    | pr_notice()                                   |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_INFO      | "6"    | pr_info()                                     |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_DEBUG     | "7"    | pr_debug() and pr_devel() 如果定义了DEBUG     |

better
(若定义了DEBUG)

> ++----------------+--------+-----------------------------------------------+
> +| KERN_DEFAULT   | ""     |                                               |
> ++----------------+--------+-----------------------------------------------+
> +| KERN_CONT      | "c"    | pr_cont()                                     |
> ++----------------+--------+-----------------------------------------------+
> +
> +
> +日志级别指定了一条消息的重要性。内核根据日志级别和当前 *console_loglevel* (一个内核变量)决
> +定是否立即显示消息(将其打印到当前控制台)。如果消息的优先级比 *console_loglevel* 高(日志级
> +别值较低),消息将被打印到控制台。
> +
> +如果省略了日志级别,则以 ``KERN_DEFAULT`` 级别打印消息。
> +
> +你可以用以下方法检查当前的 *console_loglevel* 。::

remove 。

> +
> +  $ cat /proc/sys/kernel/printk
> +  4        4        1        7
> +
> +结果显示了 *current*, *default*, *minimum* and *boot-time-default* 日志级别

and -> 和

> +
> +要改变当前的 console_loglevel,只需在 ``/proc/sys/kernel/printk`` 中写入所需的
> +级别。例如,要打印所有的消息到控制台上::
> +
> +  # echo 8 > /proc/sys/kernel/printk
> +
> +另一种方式,使用 ``dmesg``
> +
> +::
   ^^

> +
> +  # dmesg -n 5
> +
> +设置 console_loglevel 打印 KERN_WARNING (4) 或更严重的信息到控制台。更多信息参
> +见 ``dmesg(1)`` 。
> +
> +作为printk()的替代方案,你可以使用 ``pr_*()`` 来记录日志。这个系列的宏在宏名中嵌入

``pr_*()`` 别名来记录日志

> +了日志级别。例如
> +
> +::
   ^^

> +
> +  pr_info("Info message no. %d\n", msg_num);
> +
> +打印 ``KERN_INFO`` 信息。
> +
> +除了比等效的printk()调用更简洁之外,它们还可以通过pr_fmt()宏为格式字符串使用一个通用
> +的定义。例如,在源文件的顶部(在任何 " ``#include`` " 指令之前)定义这样的内容。::

remove " "

> +
> +  #define pr_fmt(fmt) "%s:%s: " fmt, KBUILD_MODNAME, __func__
> +
> +会在该文件中的每一条 pr_*() 消息前加上发起该消息的模块和函数名称。
> +
> +为了调试的目的,还有两个有条件编译的宏:
           ^^^^^^  
为了调试,还有

> +pr_debug()和pr_devel(),除非定义了 ``DEBUG`` (或者在pr_debug()的情况下定义了
> +``CONFIG_DYNAMIC_DEBUG`` ),否则它们会被编译。
> +
> +
> +函数接口

reference

> +========
> +
> +Todolist:
> +
> +   :functions: printk
> +
> +
> +   :functions: pr_emerg pr_alert pr_crit pr_err pr_warn pr_notice pr_info
> +      pr_fmt pr_debug pr_devel pr_cont

Simply use original text, this is a kernel-doc 

> -- 
> 2.27.0

Thanks,
Wu X.C.


  reply	other threads:[~2021-04-19 16:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-19 13:10 [PATCH 0/3] add three core api docs Yanteng Si
2021-04-19 13:10 ` [PATCH 1/3] docs/zh_CN: add core-api kernel-api.rst translation Yanteng Si
2021-04-19 13:35   ` Matthew Wilcox
2021-04-19 14:33     ` Wu X.C.
2021-04-30 11:06     ` Alex Shi
2021-04-30 12:34       ` Matthew Wilcox
2021-04-30 15:05         ` Alex Shi
2021-04-19 13:10 ` [PATCH 2/3] docs/zh_CN: add core-api printk-basics.rst translation Yanteng Si
2021-04-19 16:19   ` Wu X.C. [this message]
2021-04-19 13:10 ` [PATCH 3/3] docs/zh_CN: add core-api printk-formats.rst translation Yanteng Si
2021-04-20  5:28   ` Wu X.C.
2021-04-21  7:15     ` teng sterling
2021-04-21  8:11       ` Wu X.C.
2021-04-21  9:54         ` teng sterling
2021-04-23 15:22       ` teng sterling
2021-04-23 16:05         ` Wu X.C.
2021-04-20 22:03 ` [PATCH 0/3] add three core api docs Jonathan Corbet
2021-04-21  1:50   ` teng sterling

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210419161916.GA8987@bobwxc.top \
    --to=bobwxc@email.cn \
    --cc=alexs@kernel.org \
    --cc=chenhuacai@kernel.org \
    --cc=corbet@lwn.net \
    --cc=jiaxun.yang@flygoat.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=realpuyuwang@gmail.com \
    --cc=siyanteng01@gmail.com \
    --cc=siyanteng@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).