On Wed, Mar 18, 2026 at 4:55 AM Gyan Sreejith <[email protected]> wrote:
>
> Thanks a lot, Shlok, for all the changes. I have included the changes from
> topup.patch to my changes.
>
+#undef pg_log_warning
+#define pg_log_warning(...) \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_WARNING, __VA_ARGS__); \
+ pg_log_generic(PG_LOG_WARNING, PG_LOG_PRIMARY, __VA_ARGS__)
+
+#undef pg_log_warning_detail
+#define pg_log_warning_detail(...) \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_WARNING, __VA_ARGS__); \
+ pg_log_generic(PG_LOG_WARNING, PG_LOG_DETAIL, __VA_ARGS__)
+
+#undef pg_log_warning_hint
+#define pg_log_warning_hint(...) \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_WARNING, __VA_ARGS__); \
+ pg_log_generic(PG_LOG_WARNING, PG_LOG_HINT, __VA_ARGS__)
+
+#undef pg_log_info
+#define pg_log_info(...) do { \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_INFO, __VA_ARGS__); \
+ else \
+ pg_log_generic(PG_LOG_INFO, PG_LOG_PRIMARY, __VA_ARGS__); \
+} while(0)
+
+#undef pg_log_info_hint
+#define pg_log_info_hint(...) do { \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_INFO, __VA_ARGS__); \
+ else \
+ pg_log_generic(PG_LOG_INFO, PG_LOG_HINT, __VA_ARGS__); \
+} while(0)
+
+#undef pg_log_debug
+#define pg_log_debug(...) do { \
+ if (unlikely(__pg_log_level <= PG_LOG_DEBUG)) { \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_DEBUG, __VA_ARGS__); \
+ else \
+ pg_log_generic(PG_LOG_DEBUG, PG_LOG_PRIMARY, __VA_ARGS__); \
+ } \
+} while(0)
+
+#undef pg_fatal
+#define pg_fatal(...) do { \
+ if (internal_log_file_fp != NULL) \
+ internal_log_file_write(PG_LOG_ERROR, __VA_ARGS__); \
+ pg_log_generic(PG_LOG_ERROR, PG_LOG_PRIMARY, __VA_ARGS__); \
+ exit(1); \
+} while(0)
This looks odd to me. I think it would be better to encapsulate this
in one function (something like we have in pg_log_v) and then based on
log level, do required handling.
--
With Regards,
Amit Kapila.