Difference between revisions of "Manual:DIL Manual/flog()"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="bpflog"></span>
+
= flog() =
 +
'''Function''' (integer). Writes a string to a file of its own in the server's log directory.
  
−
  '''Function:'''  <i><!--CODE-->flog (filename : string, s : string, wa : string );</i><!--ENDCODE-->
+
  flog(filename : string, s : string, mode : string)
  
−
<!--TERM--> '''filename'''
+
Keeps a zone's records out of <code>vme.log</code>: the text goes to
−
<!--DEFINITION-->         The Filename of the file to appear in the log directory.
+
<code>filename</code> in the log directory (<code>logdir</code> in <code>server.cfg</code>,
−
<!--TERM--> '''s'''
+
<code>../log/</code> from <code>vme/bin</code>). The <code>bug</code>, <code>idea</code> and
−
<!--DEFINITION-->         The string to be logged.
+
<code>typo</code> commands in commands.zon collect their reports this way.
−
<!--TERM--> '''wa'''
 
−
<!--DEFINITION-->         Write or Append
 
  
−
The 'flog' function allows you to split up your logs in the log directory
+
== Parameters ==
−
so that you don't end up with everything in the main vme.log.
+
{| class="wikitable"
−
'''Note:'''The append/write argument must be in lower case and can only be a
+
! Name !! Type !! Meaning
−
'w' or a 'a' surrounded by '"'.  If the argument is a 'w' it will over write
+
|-
−
any log file by that name. If the argument is 'a' it will append to the
+
| filename || string || The file's name in the log directory. A name with <code>..</code> in it is refused.
−
file by that name.
+
|-
−
'''Example:'''
+
| s || string || The text, written as it is: no newline or time stamp is added.
−
<i><!--CODE-->
+
|-
 +
| 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.
  
−
dilbegin zonelog (s:string);
+
== Notes ==
−
code
+
* Only zones with access level 0 or 1 (the fourth column of <code>vme/etc/zonelist</code>) may
−
dilend
+
  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>.
−
</i><!--ENDCODE-->
+
* End each entry with a newline or a <code>&lt;br/&gt;</code> yourself, or the entries run
−
The previous DIL function will work in any zone to log to a file with that
+
  together.
−
zones name each zone could use it to keep zone logs separate.
 
−
 
 
−
 
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 
−
<span id="bpflog"></span>
 
−
 
 
−
'''Function:''' <i><!--CODE-->flog (filename : string,  s : string, wa : string );</i><!--ENDCODE-->
 
−
 
 
−
<!--TERM--> '''filename'''
 
−
<!--DEFINITION-->         The Filename of the file to appear in the log directory.
 
−
<!--TERM--> '''s'''
 
−
<!--DEFINITION-->         The string to be logged.
 
−
<!--TERM-->  '''wa'''
 
−
<!--DEFINITION-->        Write or Append
 
−
 
 
−
The 'flog' function allows you to split up your logs in the log directory
 
−
so that you don't end up with everything in the main vme.log.
 
−
'''Note:'''The append/write argument must be in lower case and can only be a
 
−
'w' or a 'a' surrounded by '"'.  If the argument is a 'w' it will over write
 
−
any log file by that name.  If the argument is 'a' it will append to the
 
−
file by that name.
 
−
'''Example:'''
 
−
<i><!--CODE-->
 
−
 
 
−
---~---~---~---~---~---~---~---~---
 
  
−
dilbegin zonelog (s:string);
+
== Example ==
−
code
+
<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()]]
−
</i><!--ENDCODE-->
+
* [[Manual:DIL Manual/savestr()|savestr()]]
−
The previous DIL function will work in any zone to log to a file with that
+
* [[Manual:DIL Manual/asctime()|asctime()]]
−
zones name each zone could use it to keep zone logs separate.
+
* [[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.

See also