You're browsing documentation for an old version.

View Current

Logging

LdapRecord includes an implementation of PSR's widely supported Logger interface.

By default, all of LdapRecord's events will call the logger you have set to utilize.

LdapRecord does not include a file / text logger. You must implement your own.

Registering & Enabling a Logger

To register a logger call LdapRecord\Container::setLogger(). The logger must implement the Psr\Log\LoggerInterface.

\LdapRecord\Container::setLogger($myLogger);

Disabling Logging

If you need to disable the event logger after a certain set of operations, simply pass in null and logging will be disabled:

\LdapRecord\Container::setLogger($myLogger);

$connection = new \LdapRecord\Connection(['...']);

try {
    $connection->connect();

    // Disable logging anything else.
    \LdapRecord\Container::setLogger(null);
} catch (\LdapRecord\Auth\BindException $e) {
    //
}

Logged Information

After enabling LdapRecord logging, the following events are logged:

LdapRecord\Auth\Events\Attempting

LDAP (ldap://192.168.1.1:389) - Operation: LdapRecord\Auth\Events\Attempting - Username: CN=Steve Bauman,OU=Users,DC=local,DC=com

LdapRecord\Auth\Events\Binding

LDAP (ldap://192.168.1.1:389) - Operation: LdapRecord\Auth\Events\Binding - Username: CN=Steve Bauman,OU=Users,DC=local,DC=com

LdapRecord\Auth\Events\Bound

LDAP (ldap://192.168.1.1:389) - Operation: LdapRecord\Auth\Events\Bound - Username: CN=Steve Bauman,OU=Users,DC=local,DC=com

LdapRecord\Auth\Events\Passed

LDAP (ldap://192.168.1.1:389) - Operation: LdapRecord\Auth\Events\Passed - Username: CN=Steve Bauman,OU=Users,DC=local,DC=com

LdapRecord\Auth\Events\Failed

LDAP (ldap://192.168.1.1:389) - Operation: LdapRecord\Auth\Events\Failed - Username: CN=Steve Bauman,OU=Users,DC=local,DC=com - Result: Invalid Credentials

LdapRecord\Models\Events\Saving

LDAP (ldap://192.168.1.1:389) - Operation: Saving - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Saved

LDAP (ldap://192.168.1.1:389) - Operation: Saved - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Creating

LDAP (ldap://192.168.1.1:389) - Operation: Creating - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Created

LDAP (ldap://192.168.1.1:389) - Operation: Created - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Updating

LDAP (ldap://192.168.1.1:389) - Operation: Updating - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Updated

LDAP (ldap://192.168.1.1:389) - Operation: Updated - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Deleting

LDAP (ldap://192.168.1.1:389) - Operation: Deleting - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com

LdapRecord\Models\Events\Deleted

LDAP (ldap://192.168.1.1:389) - Operation: Deleted - On: LdapRecord\Models\Entry - Distinguished Name: cn=John Doe,DC=local,DC=com
Generated on September 7, 2024
Edit on GitHub