NaviServer - programmable web server
4.99  5.0

[ Main Table Of Contents | Table Of Contents | Keyword Index ]

ns_asynclogfile(n) 4.99.30 naviserver "NaviServer Built-in Commands"

Name

ns_asynclogfile - Manage connection channels.

Table Of Contents

Synopsis

Description

The command ns_asynclogfile can be used to write application specific log file entries in an asynchronous fashion. It is based on the same infrastructure as the system log (see ns_log) or the access log (see ns_accesslog). This command is designed for small write operations in a multi-threaded environment, where potentially multiple writers perform concurrent operations.

COMMANDS

ns_asynclogfile open filename ?mode?

The command ns_asynclogfile open opens a write-only log file and returns a thread-shareable handle (actually a numeric file descriptor) which can be used in subsequent ns_asynclogfile write or ns_asynclogfile close operations.

The specified filename names the file to be opened, the optional mode is a list of entries limited to APPEND, EXCL, DSYNC, SYNC, TRUNC. The modes DSYNC and SYNC are only allowed, when supported by the used operating systems. For details on the meaning of these flags, consult the open manual page of section (2) of standard Unix manuals.

ns_asynclogfile write ?-binary? ?-sanitize sanitize? handle line

Write the provided line to an opened logfile denoted by the handle. If the line should be terminated by a new-line character, the caller has to provide this character. The option -binary should be provided for binary data. The optional parameter -sanitize can be used to sanitize the input. The default is taken from the global parameter sanitizelogfiles.

  • The value of 0 means that no sanitize should happen.

  • The value 1 means that full sanitizing is in place, which means that non-printable characters are written as hex values.

  • The a sanitize value of 2 means that sanitizing happens in a human friendly fashion: newlines are preserved, but sanitizing makes sure that multiline content cannot not confused with different log file entries. After a new-line character a continuation character starts the new line followed by 4 spaces.

ns_asynclogfile close handle

Close the logfile.

See Also

ns_accesslog, ns_log, ns_write

Keywords

log, server built-in