Skip to content

Commit

Permalink
Issue 5842 - Add log buffering for error log
Browse files Browse the repository at this point in the history
Description:

Adding log buffering for error log.  Also refactored and cleaned up some
of the code.

relates: #5842

Reviewed by: tbordaz & progier (Thanks!!)
  • Loading branch information
mreynolds389 committed Nov 12, 2024
1 parent 4c71858 commit 3ffcb34
Show file tree
Hide file tree
Showing 6 changed files with 401 additions and 227 deletions.
38 changes: 38 additions & 0 deletions dirsrvtests/tests/suites/ds_logs/ds_logs_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1369,9 +1369,47 @@ def fin():
log.info('Restore dse.ldif')
topology_st.standalone.stop()
shutil.copy(dse_ldif + '.correct', dse_ldif)
topology_st.standalone.start()

request.addfinalizer(fin)


def test_errorlog_buffering(topology_st, request):
"""Test log buffering works as expected when on or off
:id: 324ec5ed-c8ec-49fe-ab20-8c8cbfedca41
:setup: Standalone Instance
:steps:
1. Set buffering on
2. Reset logs and restart the server
3. Check for logging that should be buffered (not found)
4. Disable buffering
5. Reset logs and restart the server
6. Check for logging that should be found
:expectedresults:
1. Success
2. Success
3. Success
4. Success
5. Success
6. Success
"""

# Configure instance
inst = topology_st.standalone
inst.config.replace('nsslapd-errorlog-logbuffering', 'on')
inst.deleteErrorLogs(restart=True)

time.sleep(1)
assert not inst.ds_error_log.match(".*slapd_daemon - slapd started.*")

inst.config.replace('nsslapd-errorlog-logbuffering', 'off')
inst.deleteErrorLogs(restart=True)

time.sleep(1)
assert inst.ds_error_log.match(".*slapd_daemon - slapd started.*")


if __name__ == '__main__':
# Run isolated
# -s for DEBUG mode
Expand Down
21 changes: 21 additions & 0 deletions ldap/servers/slapd/libglobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ slapi_onoff_t init_securitylog_compress_enabled;
slapi_onoff_t init_auditlog_compress_enabled;
slapi_onoff_t init_auditfaillog_compress_enabled;
slapi_onoff_t init_errorlog_compress_enabled;
slapi_onoff_t init_errorlogbuffering;
slapi_onoff_t init_accesslog_logging_enabled;
slapi_onoff_t init_accesslogbuffering;
slapi_onoff_t init_securitylog_logging_enabled;
Expand Down Expand Up @@ -848,6 +849,10 @@ static struct config_get_and_set
NULL, 0,
(void **)&global_slapdFrontendConfig.securitylogbuffering,
CONFIG_ON_OFF, NULL, &init_securitylogbuffering, NULL},
{CONFIG_ERRORLOG_BUFFERING_ATTRIBUTE, config_set_errorlogbuffering,
NULL, 0,
(void **)&global_slapdFrontendConfig.errorlogbuffering,
CONFIG_ON_OFF, NULL, &init_errorlogbuffering, NULL},
{CONFIG_CSNLOGGING_ATTRIBUTE, config_set_csnlogging,
NULL, 0,
(void **)&global_slapdFrontendConfig.csnlogging,
Expand Down Expand Up @@ -1910,6 +1915,7 @@ FrontendConfig_init(void)
cfg->errorlog_exptimeunit = slapi_ch_strdup(SLAPD_INIT_LOG_EXPTIMEUNIT);
cfg->errorloglevel = SLAPD_DEFAULT_FE_ERRORLOG_LEVEL;
init_errorlog_compress_enabled = cfg->errorlog_compress = LDAP_OFF;
init_errorlogbuffering = cfg->errorlogbuffering = LDAP_OFF;

init_auditlog_logging_enabled = cfg->auditlog_logging_enabled = LDAP_OFF;
cfg->auditlog_log_format = slapi_ch_strdup(SLAPD_INIT_AUDITLOG_LOG_FORMAT);
Expand Down Expand Up @@ -7852,6 +7858,21 @@ config_set_accesslogbuffering(const char *attrname, char *value, char *errorbuf,
return retVal;
}

int32_t
config_set_errorlogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
{
int32_t retVal = LDAP_SUCCESS;
slapdFrontendConfig_t *slapdFrontendConfig = getFrontendConfig();

retVal = config_set_onoff(attrname,
value,
&(slapdFrontendConfig->errorlogbuffering),
errorbuf,
apply);

return retVal;
}

int32_t
config_set_auditlogbuffering(const char *attrname, char *value, char *errorbuf, int apply)
{
Expand Down
Loading

0 comments on commit 3ffcb34

Please sign in to comment.