Difference between revisions of "Manual:DIL Manual/flog()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = flog() = | |
| + | '''Function''' (integer). Writes a string to a file of its own in the server's log directory. | ||
| − | + | flog(filename : string, s : string, mode : string) | |
| − | + | Keeps a zone's records out of <code>vme.log</code>: the text goes to | |
| − | + | <code>filename</code> in the log directory (<code>logdir</code> in <code>server.cfg</code>, | |
| − | + | <code>../log/</code> from <code>vme/bin</code>). The <code>bug</code>, <code>idea</code> and | |
| − | + | <code>typo</code> commands in commands.zon collect their reports this way. | |
| − | |||
| − | |||
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| − | + | |- | |
| − | + | | filename || string || The file's name in the log directory. A name with <code>..</code> in it is refused. | |
| − | + | |- | |
| − | + | | s || string || The text, written as it is: no newline or time stamp is added. | |
| − | + | |- | |
| + | | mode || string || <code>"a"</code> to add to the end of the file, <code>"w"</code> to write from its start. Only the first letter counts, and it must be lower case. | ||
| + | |} | ||
| − | + | == Returns == | |
| + | Integer: <code>FILE_SAVED</code> (1) when written; <code>FILE_ILEGAL_OPP</code> (-1) for a bad | ||
| + | mode, an empty or unset name or mode, a name with <code>..</code>, or a name too long for the | ||
| + | path; <code>FILE_NOT_SAVED</code> (-2) when <code>s</code> is empty. The constants are in | ||
| + | <code>vme/include/vme.h</code>. It fails when an argument is a failed value. | ||
| − | + | == Notes == | |
| − | + | * Only zones with access level 0 or 1 (the fourth column of <code>vme/etc/zonelist</code>) may | |
| − | + | use it. Elsewhere it writes "attempt to access logs w/o access" to the zone's log and the | |
| − | + | program stops. | |
| − | + | * <code>"w"</code> does not empty the file first: a shorter text leaves the end of the old one | |
| − | + | behind. Logs are normally written with <code>"a"</code>. | |
| − | + | * End each entry with a newline or a <code><br/></code> yourself, or the entries run | |
| − | + | together. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | == Example == | |
| − | + | <pre> | |
| + | dilbegin zone_note(s : string); | ||
| + | var | ||
| + | i : integer; | ||
| + | code | ||
| + | { | ||
| + | i := flog(self.zoneidx + ".log", asctime(realtime) + " " + s + "<br/>", "a"); | ||
| + | return; | ||
| + | } | ||
dilend | dilend | ||
| + | </pre> | ||
| + | Adds a dated line to a log file named after the zone the unit came from. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/log()|log()]] | |
| − | + | * [[Manual:DIL Manual/savestr()|savestr()]] | |
| − | + | * [[Manual:DIL Manual/asctime()|asctime()]] | |
| − | + | * [[Manual:DIL Manual/zoneidx|zoneidx]] | |
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:20, 14 November 2026
flog()
Function (integer). Writes a string to a file of its own in the server's log directory.
flog(filename : string, s : string, mode : string)
Keeps a zone's records out of vme.log: the text goes to
filename in the log directory (logdir in server.cfg,
../log/ from vme/bin). The bug, idea and
typo commands in commands.zon collect their reports this way.
Parameters
| Name | Type | Meaning |
|---|---|---|
| filename | string | The file's name in the log directory. A name with .. in it is refused.
|
| s | string | The text, written as it is: no newline or time stamp is added. |
| mode | string | "a" to add to the end of the file, "w" to write from its start. Only the first letter counts, and it must be lower case.
|
Returns
Integer: FILE_SAVED (1) when written; FILE_ILEGAL_OPP (-1) for a bad
mode, an empty or unset name or mode, a name with .., or a name too long for the
path; FILE_NOT_SAVED (-2) when s is empty. The constants are in
vme/include/vme.h. It fails when an argument is a failed value.
Notes
- Only zones with access level 0 or 1 (the fourth column of
vme/etc/zonelist) may
use it. Elsewhere it writes "attempt to access logs w/o access" to the zone's log and the program stops.
"w"does not empty the file first: a shorter text leaves the end of the old one
behind. Logs are normally written with "a".
- End each entry with a newline or a
<br/>yourself, or the entries run
together.
Example
dilbegin zone_note(s : string);
var
i : integer;
code
{
i := flog(self.zoneidx + ".log", asctime(realtime) + " " + s + "<br/>", "a");
return;
}
dilend
Adds a dated line to a log file named after the zone the unit came from.