dba/logs  library module
R

Summary

Download log file.
Authors
  • Christian Grün, BaseX Team 2005-23, BSD License
Related documents
ViewDescriptionFormat
xqdocxqDoc xml file from the source modulexml
xqparsexqparse xml file from the source modulexml

Imports

This module is imported by 0 modules. It imports 0 modules.

Variables

3.1 $dba:CAT

Summary
Type
Source ( 1 lines)
variable $dba:CAT := 'logs'

Functions

4.1 dba:log-download

Arities: #1R

Summary
Downloads database logs.
Signatures
dba:log-download ( $name as xs:string ) as item()+
Parameters
  • name as xs:string name (date) of log file
Return
  • item() + binary data
Invoked by 0 functions from 0 modules
    Annotations (3)
    %rest:POST()
    %rest:path('/dba/log-download')
    %rest:query-param('name','{$name}')
    Source ( 9 lines)
    function dba:log-download(
      $name  as xs:string
    ) as item()+ {
      web:response-header(
        map { 'media-type': 'text/plain' },
        map { 'Content-Disposition': 'attachment; filename=' || $name || '.log' }
      ),
      file:read-binary(db:option('dbpath') || '/.logs/' || $name || '.log')
    }

    Namespaces

    The following namespaces are defined:

    PrefixUri
    dbhttp://basex.org/modules/db
    dbadba/logs 2
    filehttp://expath.org/ns/file
    resthttp://exquery.org/ns/restxq
    webhttp://basex.org/modules/web
    xshttp://www.w3.org/2001/XMLSchema

    6 RestXQ

    Paths defined 1.

    PathMethodFunction
    /dba/log-downloadPOSTdba:log-download#1

    Source Code

    (:~
     : Download log file.
     :
     : @author Christian Grün, BaseX Team 2005-23, BSD License
     :)
    module namespace dba = 'dba/logs';
    
    (:~ Top category :)
    declare variable $dba:CAT := 'logs';
    
    (:~
     : Downloads database logs.
     : @param  $name  name (date) of log file
     : @return binary data
     :)
    declare
      %rest:POST
      %rest:path('/dba/log-download')
      %rest:query-param('name', '{$name}')
    function dba:log-download(
      $name  as xs:string
    ) as item()+ {
      web:response-header(
        map { 'media-type': 'text/plain' },
        map { 'Content-Disposition': 'attachment; filename=' || $name || '.log' }
      ),
      file:read-binary(db:option('dbpath') || '/.logs/' || $name || '.log')
    };