increased `make test` logging in syslog with "debug syslog format = always"

Douglas Bagnall douglas.bagnall at catalyst.net.nz
Fri Aug 25 03:15:59 UTC 2023


On 26/07/23 22:33, Martin Schwenke wrote:
> 
> Can we just call debug_file_log() directly when necessary, like this?
>

The answer is yes.

> diff --git a/lib/util/debug.c b/lib/util/debug.c
> index b83075cb239..0e13fa564e3 100644
> --- a/lib/util/debug.c
> +++ b/lib/util/debug.c
> @@ -1559,25 +1559,10 @@ void check_log_size( void )
>   static void Debug1(const char *msg, size_t msg_len)
>   {
>   	int old_errno = errno;
> -	enum debug_logtype logtype = state.logtype;
>   
>   	debug_count++;
>   
> -	if (state.settings.debug_syslog_format == DEBUG_SYSLOG_FORMAT_ALWAYS) {
> -		switch(state.logtype) {
> -		case DEBUG_STDOUT:
> -		case DEBUG_STDERR:
> -		case DEBUG_DEFAULT_STDOUT:
> -		case DEBUG_DEFAULT_STDERR:
> -			/* Behave the same as logging to a file */
> -			logtype = DEBUG_FILE;
> -			break;
> -		default:
> -			break;
> -		}
> -	}
> -
> -	switch(logtype) {
> +	switch(state.logtype) {
>   	case DEBUG_CALLBACK:
>   		debug_callback_log(msg, msg_len, current_msg_level);
>   		break;
> @@ -1585,13 +1570,18 @@ static void Debug1(const char *msg, size_t msg_len)
>   	case DEBUG_STDERR:
>   	case DEBUG_DEFAULT_STDOUT:
>   	case DEBUG_DEFAULT_STDERR:
> -		if (dbgc_config[DBGC_ALL].fd > 0) {
> -			ssize_t ret;
> -			do {
> -				ret = write(dbgc_config[DBGC_ALL].fd,
> -					    msg,
> -					    msg_len);
> -			} while (ret == -1 && errno == EINTR);
> +		if (state.settings.debug_syslog_format ==
> +		    DEBUG_SYSLOG_FORMAT_ALWAYS) {
> +			debug_file_log(current_msg_level, msg, msg_len);
> +		} else {
> +			if (dbgc_config[DBGC_ALL].fd > 0) {
> +				ssize_t ret;
> +				do {
> +					ret = write(dbgc_config[DBGC_ALL].fd,
> +						    msg,
> +						    msg_len);
> +				} while (ret == -1 && errno == EINTR);
> +			}
>   		}
>   		break;
>   	case DEBUG_FILE:
> 
> I haven't tested this.

I did. It worked -- or at least it returned things to where they were at 
some point in the past when syslog would get just the copyright lines 
from every make test.

I forgot about this all because I had `logging = file` in my working 
tree's selftest/target/Samba4.pm, which made even the copyrights shut up.

> If it is OK, I think we could also revert the changes to
> dbghdrclass(), though we would be generating a header for no
> reason... but I think we did that before.

Yeah. I will make an MR in a few days unless you do first.


Douglas



More information about the samba-technical mailing list