Simple Logger

Share your scripts and packages with other Mudlet users.
syrik
Posts: 90
Joined: Sat Jun 26, 2010 9:57 pm

Re: Simple Logger

Post by syrik »

How would I go about making one using screendump?

User avatar
Proxy
Posts: 27
Joined: Sun May 08, 2016 4:57 pm

Re: Simple Logger

Post by Proxy »

Is there any way this logger could be used to catch echos sent by an alias or trigger?

User avatar
Belgarath
Posts: 232
Joined: Fri Jul 26, 2013 7:19 am
Discord: macjabeth#7149

Re: Simple Logger

Post by Belgarath »

Code: [show] | [select all] lua
local oldecho = echo
function echo(str)
  oldecho(str)
  if Logger.trigger_id then
    Logger:Log(Logger.logging_file, str)
  end
end

User avatar
Proxy
Posts: 27
Joined: Sun May 08, 2016 4:57 pm

Re: Simple Logger

Post by Proxy »

Thank you so much, Belgarath! I have been trying to get that done for soo bloody long. Much appreciated!

User avatar
Proxy
Posts: 27
Joined: Sun May 08, 2016 4:57 pm

Re: Simple Logger

Post by Proxy »

I know I have been a pain in the ass, but is there any way that this logger could be used to append all logs to a single text file? In other words whenever you log in, that days log just gets added to the file and so on, leaving only one neat text file in you directory. I tried fiddling around with it but couldn't figure how to do it. Assuming the name of the file was "Test", how would I set this up, if at all possible?

Thank you all for your help

User avatar
SlySven
Posts: 1019
Joined: Mon Mar 04, 2013 3:40 pm
Location: Deepest Wiltshire, UK
Discord: SlySven#2703

Re: Simple Logger

Post by SlySven »

The normal "C" code way is to open the file in an "append" mode rather than a "create" mode - and given that Lua is built from C I suspect there is a way to tell it to open a fixed name file (rather than creating a new one each time based on the current day or whatever) in append mode.

RTFM as they say and, if it is the Lua io library that is being used, the bit of the M you ought to R is here... :P

User avatar
Proxy
Posts: 27
Joined: Sun May 08, 2016 4:57 pm

Re: Simple Logger

Post by Proxy »

Thanks for the tip, SlySven! :)

kitchen
Posts: 5
Joined: Mon Jan 08, 2018 6:32 am

Re: Simple Logger

Post by kitchen »

This is neat an real helpful. Thanks for making the script!

Quick question: is there a way to make it so that it doesn't log the same thing twice. As in it will detect if there's a duplicate entry contained in the log and stop logging if the information is already contained in the log.

What I'm using it for is logging when I identify an item and don't need to have duplicate log entries if I identify the same item twice.

Post Reply