This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Any way to ignore emails ?

Discussion of Eggdrop's code and module programming in C.
Post Reply
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Any way to ignore emails ?

Post by CrazyCat »

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
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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: Select all

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
Last edited by nml375 on Wed Oct 05, 2011 12:31 pm, edited 1 time in total.
NML_375
User avatar
CrazyCat
Revered One
Posts: 1306
Joined: Sun Jan 13, 2002 8:00 pm
Location: France
Contact:

Post by CrazyCat »

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 :)
Post Reply