Another Log implementation

Vincent thornik at gmail.com
Mon May 30 02:18:06 PDT 2011


On Mon, 30 May 2011 01:32:44 +0200, Daniel Gibson <metalcaedes at gmail.com>  
wrote:

> So if it's just "EmailLogEngine" or whatever and it's using SMTP,
> changing it to use the SMTP-alternative....

It's just a wrong view on a whole conception. Log uses different KIND of  
targets: file, database(do you care which one??), mail (is it important  
which proto??), etc.
'Mail' is an abstraction of "something which can send message to the  
human". So... instead of making annoying set of classes for all known mail  
protocols, we use ONE mail class with appropriate constructors for all  
imaginable protocols. Say:

enum MailProto { SMTP, IMAP }

class EmailLogEngine : LogEngine
{
     public this(MailProto type, string user, string psw, string host, int  
port = 0)
     {
         if (port == 0)
             switch(type) {
             case SMTP: port = 25; break;
             }

         // initialize mail server structures
     }

     override public void Write(string msg)
     {
         // send message, using appropriate proto
     }
}


More information about the Digitalmars-d mailing list