egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Any way to ignore emails ?

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming
View previous topic :: View next topic  
Author Message
CrazyCat
Master


Joined: 13 Jan 2002
Posts: 476
Location: France

PostPosted: Tue Oct 04, 2011 9:14 am    Post subject: Any way to ignore emails ? Reply with quote

Hello there,

I'm looking for a way to modify the logfile generated with eggdrop. I want to replace any email by a string, like <email> (or anything else.
So, I'm looking on the way to create a module overriding the logging system to apply a regexp replace.
But, I can't find out the way actually.

If anyone of you could give me a small help (a start point ?), I think I'll do that soon.

Regards
_________________
http://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2831

PostPosted: Tue Oct 04, 2011 1:06 pm    Post subject: Reply with quote

In 1.6.20, you could completely replace the logfile writers with tcl-code using the LOG binding. A very rough implementation would be something like this:
Code:
bind log - * myLogWriter

proc myLogWriter {level channel message} {
  #Select which file to write the log entry to. This one is based on the channel name.
  switch -exact -- [string tolower $channel] {
    "#channel1" {set file "channel1"}
    "#channel2" {set file "channel2"}
    default {set file "eggdrop"}
  }
  set fileId [open "logs/${file}.log" "APPEND CREAT WRONLY"]
  #do regexp's, etc, on message here...
  #...

  puts $fileId "[strftime {[%d %b %Y - %H:%M]}] $level: $message"

  close $fileId
}


It doesn't exactly match eggdrop's logging format, but that could fairly easily be adopted. This could also be re-written to send all log entries to an SQL-database or syslog.

It's not quite what you asked for, but you could implement a similar solution using modules as well. As for the actual logging code, it's mainly located in src/misc.c along with other misc stuff...

edit: Fixed typo in switch: Should be -exact, not --exact
_________________
NML_375, idling at #eggdrop@IrcNET


Last edited by nml375 on Wed Oct 05, 2011 12:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
CrazyCat
Master


Joined: 13 Jan 2002
Posts: 476
Location: France

PostPosted: Wed Oct 05, 2011 8:43 am    Post subject: Reply with quote

Well, this solution is good for me, I didn't notice the bind LOG in 1.6.20.

I'll use it, peharps a new tcl will come soon Smile
_________________
http://www.eggdrop.fr - French speaking IRC network
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Modules & Programming All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber