Admin Functions
This module contains functions for performing admin-centric operations such as managing database users and log data.
Conventions
All functions and errors in this module are assigned to thehttp://basex.org/modules/admin namespace, which is statically bound to the admin prefix.
Database Logs
admin:logs
| Signature | admin:logs( $date as xs:string := (), $merge as xs:boolean? := false() ) as element()* |
|---|---|
| Summary | Returns Logging data compiled by the database or HTTP server:
|
| Examples | May return a result similar to <file size="834367"/>2024-06-01</file> if a single log file exists.Lists the contents of all log files. |
admin:write-log
| Signature | admin:write-log( $message as xs:string, $type as xs:string := () ) as empty-sequence() | ||
|---|---|---|---|
| Summary | Writes a log $message to the database logs, along with current user data (timestamp, username). An optional log $type can be specified. If omitted, the log type is INFO. If the function is called from a database client, the IP will be logged. Otherwise, the string SERVER will be logged. | ||
| Errors |
|
admin:delete-logs
| Signature | admin:delete-logs( $date as xs:string ) as empty-sequence() | ||||
|---|---|---|---|---|---|
| Summary | Deletes the log entries from the specified $date. | ||||
| Errors |
|
Database Sessions
admin:sessions
| Signature | admin:sessions() as element(session)* |
|---|---|
| Summary | Returns an element sequence with all currently opened database sessions, including the username, address (IP:port) and an optionally opened database. The output of this function and the SHOW SESSIONS command is similar. |
| Examples | May e.g. return <session user="admin" address="127.0.0.1:6286" database="factbook"/>. |
Errors
| Code | Description |
|---|---|
delete | An error occurred while deleting a log file. |
today | Today’s log file cannot be deleted. |
type | Type string contains whitespace. |
Changelog
Version 9.2- Updated:
admin:write-log: type string may contain more characters
- Updated: Error codes updated; errors now use the module namespace
- Updated:
admin:write-log: optional log type added
- Added:
admin:delete-logs
- Added:
admin:write-log - Deleted:
admin:users(renamed touser:list-details)
- Updated:
admin:users: md5-encoded password added to output - Updated:
admin:logs: represent name of log files as string value;$mergeargument added
- Added: New module added.
⚡Generated with XQuery