+/*
+ * GUC_complaint_elevel
+ * Get the ereport error level to use in an assign_hook's error report.
+ *
+ * This should be used by assign hooks that want to emit a custom error
+ * report (in addition to the generic "invalid value for option FOO" that
+ * guc.c will provide). Note that the result might be ERROR or a lower
+ * level, so the caller must be prepared for control to return from ereport,
+ * or not. If control does return, return false/NULL from the hook function.
+ *
+ * At some point it'd be nice to replace this with a mechanism that allows
+ * the custom message to become the DETAIL line of guc.c's generic message.
+ */
+int
+GUC_complaint_elevel(GucSource source)
+{
+ int elevel;
+
+ if (source == PGC_S_FILE)
+ {
+ /*
+ * To avoid cluttering the log, only the postmaster bleats loudly
+ * about problems with the config file.
+ */
+ elevel = IsUnderPostmaster ? DEBUG3 : LOG;
+ }
+ else if (source == PGC_S_OVERRIDE)
+ {
+ /*
+ * If we're a postmaster child, this is probably "undo" during
+ * transaction abort, so we don't want to clutter the log. There's
+ * a small chance of a real problem with an OVERRIDE setting,
+ * though, so suppressing the message entirely wouldn't be desirable.
+ */
+ elevel = IsUnderPostmaster ? DEBUG5 : LOG;
+ }
+ else if (source < PGC_S_INTERACTIVE)
+ elevel = LOG;
+ else
+ elevel = ERROR;
+
+ return elevel;
+}
+
+