<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.mudlet.org/index.php?action=history&amp;feed=atom&amp;title=Simple_logger</id>
	<title>Simple logger - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.mudlet.org/index.php?action=history&amp;feed=atom&amp;title=Simple_logger"/>
	<link rel="alternate" type="text/html" href="https://wiki.mudlet.org/index.php?title=Simple_logger&amp;action=history"/>
	<updated>2026-06-05T18:14:19Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.0</generator>
	<entry>
		<id>https://wiki.mudlet.org/index.php?title=Simple_logger&amp;diff=20792&amp;oldid=prev</id>
		<title>Zooka: initial creation</title>
		<link rel="alternate" type="text/html" href="https://wiki.mudlet.org/index.php?title=Simple_logger&amp;diff=20792&amp;oldid=prev"/>
		<updated>2024-01-18T14:04:43Z</updated>

		<summary type="html">&lt;p&gt;initial creation&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;[[Category:Mudlet Package Listing]]&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;width: 70%;&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;width: 10%&amp;quot; | Game || non-mud specific&lt;br /&gt;
|-&lt;br /&gt;
| By || Wyd&lt;br /&gt;
|-&lt;br /&gt;
| Download || https://forums.mudlet.org/download/file.php?id=307&amp;amp;sid=ee16e5b03abb9d132a2a95bfd37f48fb&lt;br /&gt;
|-&lt;br /&gt;
| Dependencies || &amp;lt;!-- any package dependencies|mudlet version requirements --&amp;gt; Mudlet 4.17&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Description =  &lt;br /&gt;
&amp;lt;!-- A description about what your script accomplishes. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The Simple logger is a basic logging system for Mudlet, that allows you to log text out to a file. The difference between this logger and the inbuild mudlet one, is that the Simple Logger allows you to log out only certain lines (For example, &amp;quot;You have slain &amp;lt;blah&amp;gt;.&amp;quot;), or split your log files up into files of a certain size.&lt;br /&gt;
&lt;br /&gt;
= Usage =&lt;br /&gt;
&amp;lt;!-- include function parameters and some usage details (either screenshots or &amp;lt;code&amp;gt;preformatted script output&amp;lt;/code&amp;gt; so players can understand how to use your script --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:Log(file, line_to_save, options_table)&amp;lt;/code&amp;gt; - Simply appends &amp;lt;code&amp;gt;line_to_save&amp;lt;/code&amp;gt; to &amp;lt;code&amp;gt;file.txt&amp;lt;/code&amp;gt;. See the &amp;quot;options&amp;quot; section below to see the currently valid options.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:LogSection(file, options_table)&amp;lt;/code&amp;gt; - The logger will append every line that comes from the MUD until you call &amp;lt;code&amp;gt;Logger:StopLogging()&amp;lt;/code&amp;gt;. Not, this will only output stuff directly from the MUD, and not show echo&amp;#039;s or such. See the &amp;quot;options&amp;quot; section below to see the currently valid options.  When you log a section, the logged output will be put between &amp;lt;code&amp;gt;[[[START OF SECTION]]]&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;[[[END OF SECTION]]]&amp;lt;/code&amp;gt; to make sections easier to find.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:StopLogging()&amp;lt;/code&amp;gt; - Stops logging after &amp;lt;code&amp;gt;Logger:LogSection()&amp;lt;/code&amp;gt; is called.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:SearchLog(file, pattern)&amp;lt;/code&amp;gt; - Searches through &amp;lt;code&amp;gt;file.txt&amp;lt;/code&amp;gt; for the given pattern, and output matched lines. This uses rex_pcre to search, so the pattern can be regular expression.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:CloseLog(file)&amp;lt;/code&amp;gt; - To be used with the &amp;lt;code&amp;gt;keepOpen&amp;lt;/code&amp;gt; option (explained below). The &amp;lt;code&amp;gt;file&amp;lt;/code&amp;gt; parameter is optional, and if omitted, then the Logger will close all open log files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are currently three recognized options:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;timestamp&amp;lt;/code&amp;gt; - When included in the options table, the Logger will prefix each logged line with a time stamp.  Note: Dates in the order (dd/mm/yyyy).  If you want to change this around, just modify the &amp;lt;code&amp;gt;time_format&amp;lt;/code&amp;gt; variable in &amp;lt;code&amp;gt;Logger:Log()&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;split = &amp;lt;number&amp;gt;&amp;lt;/code&amp;gt; - This tells the logger to ensure that the log file gets no larger then &amp;lt;code&amp;gt;&amp;lt;number&amp;gt;&amp;lt;/code&amp;gt; kilobytes. If the log file gets larger then the given number, the logger will backup the old file.txt, and create a new one. If this option is used with &amp;lt;code&amp;gt;Logger:Log()&amp;lt;/code&amp;gt;, then it will check each time the function is called. With &amp;lt;code&amp;gt;Logger:LogSection()&amp;lt;/code&amp;gt;, the file size is checked when logging first begins, and every 10 minutes after that, for performance reasons.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;keepOpen&amp;lt;/code&amp;gt; - This option tells the Logger to not close the handle to the log file, and to keep it open until &amp;lt;code&amp;gt;Logger:CloseLog(file)&amp;lt;/code&amp;gt; is called. This allows a substantial performance gain when logging large amounts of data at once. If you use this, then &amp;lt;code&amp;gt;Logger:CloseLog()&amp;lt;/code&amp;gt; should be called when you close the connection to your MUD, to ensure that the Logger closes all open logs.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: &amp;lt;code&amp;gt;LogSection&amp;lt;/code&amp;gt; uses &amp;lt;code&amp;gt;keepOpen&amp;lt;/code&amp;gt; by default, and closes the log when the logging is stopped. This means you&amp;#039;ll need to ensure that &amp;lt;code&amp;gt;Logger:StopLogging()&amp;lt;/code&amp;gt; is called at some point.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Two examples of using the option table would be;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:Log(&amp;quot;kills&amp;quot;, { &amp;quot;timestamp&amp;quot;})&amp;lt;/code&amp;gt;&lt;br /&gt;
* &amp;lt;code&amp;gt;Logger:LogSection(&amp;quot;arena&amp;quot;, {split = 5000})&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
See also: [https://forums.mudlet.org/viewtopic.php?f=6&amp;amp;t=1424 Mudlet Forums]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= Examples =&lt;br /&gt;
&lt;br /&gt;
I have included the following aliases to demonstrate its use:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;log &amp;lt;file&amp;gt;&amp;lt;/code&amp;gt; - Will call &amp;lt;code&amp;gt;Logger:LogSection(&amp;lt;file&amp;gt;)&amp;lt;/code&amp;gt;. If &amp;lt;code&amp;gt;&amp;lt;type&amp;gt;&amp;lt;/code&amp;gt; is &amp;quot;off&amp;quot;, it will call &amp;lt;code&amp;gt;Logger:StopLogging()&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;searchlog &amp;lt;file&amp;gt; &amp;lt;pattern&amp;gt;&amp;lt;/code&amp;gt; - Will call &amp;lt;code&amp;gt;Logger:SearchLog(&amp;lt;type&amp;gt;, &amp;lt;pattern&amp;gt;)&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* A &amp;quot;slain&amp;quot; trigger for Achaea to demonstrate how to use the &amp;lt;code&amp;gt;Logger:Log()&amp;lt;/code&amp;gt; function.&lt;/div&gt;</summary>
		<author><name>Zooka</name></author>
	</entry>
</feed>