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

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="bplog"></span>
+
= log() =
−
log( s : string )
+
'''Procedure.''' Writes a line to the server log.
−
    s : Text to put in the log.
 
−
    result: Puts text in the log for debugging purposes.
 
  
−
---~---~---~---~---~---~---~---~---
+
  log(s : string)
−
<span id="bplog"></span>
 
−
  log( s : string )
 
−
    s : Text to put in the log.
 
−
    result: Puts text in the log for debugging purposes.
 
  
−
---~---~---~---~---~---~---~---~---
+
Writes <code>s</code> to <code>vme.log</code> (in <code>vme/bin</code>), after the time and the
 +
name of the zone: <code>zone/text</code>. The zone is that of the unit the program runs on,
 +
which for a program on a player is <code>_players</code>. The line is also added to that zone's
 +
<code>.err</code> file in the zone directory (<code>zondir</code> in <code>server.cfg</code>),
 +
and gods who follow the log in the game see it as <code>(LOG: zone/text)</code>.
 +
 
 +
Use it for errors a builder or admin should see, and for tracing a program while writing it.
 +
Players never see it.
 +
 
 +
== Parameters ==
 +
{| class="wikitable"
 +
! Name !! Type !! Meaning
 +
|-
 +
| s || string || The text.
 +
|}
 +
 
 +
== Notes ==
 +
* <code>vme.log</code> starts empty at every boot.
 +
* The server stops itself when it has written 80 MB of log since boot ("Log-file insanely big! Going down."). Don't log on every tick, every command, or in a loop.
 +
* A null string writes nothing.
 +
 
 +
== Example ==
 +
<pre>
 +
dilbegin count_inside(u : unitptr);
 +
var
 +
  n : integer;
 +
  item : unitptr;
 +
code
 +
{
 +
  item := u.inside;
 +
  while (item != null)
 +
  {
 +
      n := n + 1;
 +
      item := item.next;
 +
  }
 +
  if (n > 50)
 +
      log(u.symname + " holds " + itoa(n) + " units");
 +
  return;
 +
}
 +
dilend
 +
</pre>
 +
Counts the units in a container and logs it when there are suspiciously many.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/flog()|flog()]]
 +
* [[Manual:DIL Manual/logcrime()|logcrime()]]
 +
* [[Manual:DIL Manual/dispatch()|dispatch()]]

Latest revision as of 23:22, 14 November 2026

log()

Procedure. Writes a line to the server log.

log(s : string)

Writes s to vme.log (in vme/bin), after the time and the name of the zone: zone/text. The zone is that of the unit the program runs on, which for a program on a player is _players. The line is also added to that zone's .err file in the zone directory (zondir in server.cfg), and gods who follow the log in the game see it as (LOG: zone/text).

Use it for errors a builder or admin should see, and for tracing a program while writing it. Players never see it.

Parameters

Name Type Meaning
s string The text.

Notes

  • vme.log starts empty at every boot.
  • The server stops itself when it has written 80 MB of log since boot ("Log-file insanely big! Going down."). Don't log on every tick, every command, or in a loop.
  • A null string writes nothing.

Example

dilbegin count_inside(u : unitptr);
var
   n : integer;
   item : unitptr;
code
{
   item := u.inside;
   while (item != null)
   {
      n := n + 1;
      item := item.next;
   }
   if (n > 50)
      log(u.symname + " holds " + itoa(n) + " units");
   return;
}
dilend

Counts the units in a container and logs it when there are suspiciously many.

See also