Manual:DIL Manual/flog()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:20, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.

See also