Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vH1N5-00BArJ-Md for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Nov 2025 14:53:55 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1vH1N3-008Xgz-71 for pgsql-hackers@arkaria.postgresql.org; Thu, 06 Nov 2025 14:53:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vH1N2-008Xgq-Sy for pgsql-hackers@lists.postgresql.org; Thu, 06 Nov 2025 14:53:51 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vH1Mz-006K8o-0W for pgsql-hackers@lists.postgresql.org; Thu, 06 Nov 2025 14:53:51 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-7a9c64dfa6eso916856b3a.3 for ; Thu, 06 Nov 2025 06:53:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762440827; x=1763045627; darn=lists.postgresql.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=NHNE81yNvL7xMp//cxQwA8UEi4peJT0+QvjU8Cp4I7A=; b=O9S6QPEpH62djSgiQnQ5ma5fGRRApDrCDhWXJv9uRNjk7+1vAyAwiLKicEyAqaJFSc BP8DVZch+GwJsajNWH7P8z2Sjhnnr4gyoH5fpxn/dPt7mu2vUSm8Zl12SPmPjZL1Tk4q d2KdhGdtH6EFfKNcKpcosXJ76lqIAz37d+7nHn+KM4AQtKjKO0wB6tuJdqSfYn45g8ZO I4+OniKIJ4lZr1GJFQxUfvB5edfiRlAgWpEQ02SI92OO4lMwxelsOe1gfSjYa79Nkpb0 Uw9sE5LpTMZWSJaCqrVgPcaxy4aJHntTutXAjrIXFBEWaB0tQLkdde5LLo6BIcdtRnvf Azyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762440827; x=1763045627; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NHNE81yNvL7xMp//cxQwA8UEi4peJT0+QvjU8Cp4I7A=; b=DDk0yd0GP2F0s+rmXxNgoGAPSdeXfbH8Ebp8AUSS0II8kC8NeZaLtQwjzKzQA/Gdp8 Aqd3GqJJXLemyh2sQTfs9lCmENKC5fjK3RWD0bIK742grTyZSRgGhshPY2m09AxYxS/v 7QHAJuqrIHg+0DPEsi6q9VvMPgE8jNFflSTMnzPXh8R7DdxzvoCIoMvLZFq43z8F1aQN Kel0ZwsPWgz68oHKx7Gc9dS2hvlgHO3FtsmiKsg4OpqxMmGgqVCDXE6VZUw/UQCRSEeu UJuulFBEFtijZKRes6ZcIwAUh9CHbleZoM7tOVWHboBJJzpeBIGPZsbqer72Ml2Yyzb3 Fa3w== X-Forwarded-Encrypted: i=1; AJvYcCUcUPZLc8XYekexxep4Y8twG/MXHGSz9rADVMawr0Va2xDqNejkFiBPJlFYBhuQfres0VP+eAP/2Lc1g+NO@lists.postgresql.org X-Gm-Message-State: AOJu0YyISgSOcUTinpsD3NmHikcfZ0db8/W4K1hp2ctI82muJaxsPNnf U090PM6m3BuM8w/8ckGI9V1tvpJOTdfHLjw4ABkKTFyFv27mEvP8pAmN X-Gm-Gg: ASbGnctlcwfvwq2XQFbik/OvN8dfBuuxxyx9dLu/n+qw1Gu/P4jzaGWRe/xdvXQ0X9v G8Fa6mu/QG9oTBKa/wZNS5+afdWiRanZuAkTqLiD3pcI5anWndqXwYkt0AkNF21weT08FaAa3qZ bRj0UyYs9em6Ca2hjnxHJDAimxxjK7Ibb/C6Gt2EL5/lXQ5Gs5Ro6wTypb/TPHNkX5k8W/Drv+2 NNASoDvOyTqL5DYuGb8zq3bRaD2KrcDO3CvucOXtXr73NhmRmkCOejU9X2w/312CGGwZ/mptY+S zSS7KIUnsP/ogebjQD0Ne+sEMlwWYBLxx8bm82mAdjtU1JEwqXFiB7cWHNbzsvLBaU9ygW6aqYV C2M8pSLKR2f8pk1GV8PQr7kP+d2YbJpHBMK5LZ6Ktqgkdyn5xuJQmSLsgvaxOA/a3N83o0jEw34 VsGxqAwVmTNNStHmYB7RalEA== X-Google-Smtp-Source: AGHT+IGs6NwC+HPJcyzrSrINAGlrcfixfPUoZYf88aIlg5OGTNqQlUHyA6JDO4016KdwpR5FoYbTNQ== X-Received: by 2002:a05:6a21:338a:b0:344:97a7:8c68 with SMTP id adf61e73a8af0-34f86114a51mr9230335637.54.1762440826583; Thu, 06 Nov 2025 06:53:46 -0800 (PST) Received: from smtpclient.apple ([170.178.170.211]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-ba8f9ed21f6sm2874407a12.13.2025.11.06.06.53.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Nov 2025 06:53:45 -0800 (PST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.700.81\)) Subject: Re: log_min_messages per backend type From: Chao Li In-Reply-To: <72e809ff-c842-4f98-93f1-26a3cb3d92d0@app.fastmail.com> Date: Thu, 6 Nov 2025 22:53:00 +0800 Cc: japin , Alvaro Herrera , Andres Freund , pgsql-hackers@lists.postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: <8AF30EAA-2E9F-4398-B4C6-24C4480CA869@gmail.com> References: <202507311651.ahhz57cfk6lo@alvherre.pgsql> <24b9bfd6-7fba-4946-9b73-244934b89464@app.fastmail.com> <72e809ff-c842-4f98-93f1-26a3cb3d92d0@app.fastmail.com> To: Euler Taveira X-Mailer: Apple Mail (2.3826.700.81) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi Euler, I just reviewed the patch and got a few comments. > On Nov 6, 2025, at 21:09, Euler Taveira wrote: >=20 > On Sun, Oct 5, 2025, at 11:18 AM, Euler Taveira wrote: >> This new patch contains the following changes: >>=20 >> - patch was rebased >> - use commit dbf8cfb4f02 >> - use some GUC memory allocation functions >> - avoid one memory allocation (suggested by Japin Li) >> - rename backend type: logger -> syslogger >> - adjust tests to increase test coverage >> - improve documentation and comments to reflect the current state >>=20 >=20 > Patch was rebased since commit fce7c73fba4 broke it. No modifications. >=20 >=20 > --=20 > Euler Taveira > EDB = https://www.enterprisedb.com/ 1 - variable.c ``` + /* Initialize the array. */ + memset(newlevel, WARNING, BACKEND_NUM_TYPES * sizeof(int)); ``` I think this statement is wrong, because memset() writes bytes but = integers, so this statement will set very byte to WARNING, which should = not be the intention. You will need to use a loop to initialize every = element of newlevel. 2 - variable.c ``` + /* Parse string into list of identifiers. */ + if (!SplitGUCList(rawstring, ',', &elemlist)) + { + /* syntax error in list */ + GUC_check_errdetail("List syntax is invalid."); + guc_free(rawstring); + list_free(elemlist); + return false; + } ``` Every element of elemlist points to a position of rawstring, so it=E2=80=99= s better to list_free(elemlist) first then guc_free(rawstring). 3 - launch_backend.c ``` static inline bool should_output_to_server(int elevel) { - return is_log_level_output(elevel, log_min_messages); + return is_log_level_output(elevel, = log_min_messages[MyBackendType]); } ``` Is it possible that when this function is called, MyBackendType has not = been initialized? To be safe, maybe we can check if MyBackendType is 0 = (B_INVALID), then use the generic log_min_message. 4 - config.sgml ``` + Valid values are a comma-separated list of = backendtype:level + and a single level. The list allows it to = use + different levels per backend type. Only the single = level + is mandatory (order does not matter) and it is assigned to the = backend + types that are not specified in the list. + Valid backendtype values are = archiver, + autovacuum, backend, + bgworker, bgwriter, + checkpointer, ioworker, + syslogger, = slotsyncworker, + startup, walreceiver, + walsender, walsummarizer, = and + walwriter. + Valid level values are = DEBUG5, + DEBUG4, DEBUG3, = DEBUG2, + DEBUG1, INFO, = NOTICE, + WARNING, ERROR, = LOG, + FATAL, and PANIC. Each = level includes + all the levels that follow it. The later the level, the fewer = messages are sent + to the log. The default is WARNING for all = backend types. + Note that LOG has a different rank here than = in ``` * =E2=80=9CValid values are =E2=80=A6=E2=80=9D, here =E2=80=9Care=E2=80=9D= usually mean both are needed, so maybe change =E2=80=9Care=E2=80=9D to = =E2=80=9Ccan be=E2=80=9D. * It says =E2=80=9Cthe single level is mandatory=E2=80=9D, then why = there is still a default value? Best regards, -- Chao Li (Evan) HighGo Software Co., Ltd. https://www.highgo.com/