The test module defines some common components and imports that are useful for testing your application's logging behavior.

Do not import this module outside the scope of any test code/unittests, as it may interfere with normal SLF4D operations.

Public Imports

public import slf4d;

A convenience import of the main SLF4D package.

public import slf4d.testing_provider;

Imports the testing provider, since that's needed for most SLF4D-related tests.



void acquireLoggingTestingLock()

Acquires a lock for the SLF4D testing system. Call this before testing anything which interacts with a pre-configured testing setup for logging.

TestingLoggingProvider getTestingProvider()

Resets the SLF4D logging state, and configures a new TestingLoggingProvider to be used, and returns it. This should only be called when you've acquired a lock for the testing system (or synchronized on the mutex).

void releaseLoggingTestingLock()

Releases a lock for the SLF4D testing system. Call this after testing anything that required the lock to be acquired.

void withTestingLock(void delegate() dg)

Convenience function to acquire a lock on the SLF4D logging state and run some code, then reset the logging state and release the lock.

void withTestingProvider(void delegate(TestingLoggingProvider) dg)

Convenience function to acquire a lock on the testing state, run some code (in the provided delegate function), then release the lock.

Static variables

Mutex loggingTestingMutex;

A mutex to synchronize tests that affect the core logging state. You can either synchronize on this object, or call acquireLoggingTestingLock() to ensure that only your test has access to the logging state. Be sure that if you acquire a testing lock, that you release it afterwards with releaseLoggingTestingLock().