pike.git / lib / modules / Search.pmod / Utils.pmod

version» Context lines:

pike.git/lib/modules/Search.pmod/Utils.pmod:665:   //!   class Logger {       private string|Sql.Sql logdb;    private int profile;    private int stderr_logging;       private int last_log_purge_time;    private constant log_purge_freq = 8*60*60; // Purge log every 8 h or so.    +  private string indentation = " "; +     private Sql.Sql get_db() {    Sql.Sql db;   #if constant(DBManager)    if(stringp(logdb))    db = DBManager.get(logdb);    else   #endif    db = logdb;       // if(!logdb || !logdb->query)    // throw( ({ "Couldn't find any database object.\n", backtrace() }) );       return db;    }       //! @decl void create(Sql.Sql db_object, int profile, int stderr_logging)    //! @decl void create(string db_url, int profile, int stderr_logging)    protected void create(string|Sql.Sql _logdb, int _profile, -  int _stderr_logging) { +  int _stderr_logging, +  void|int indentation_width) +  {    logdb = _logdb;    profile = _profile;    stderr_logging = _stderr_logging; -  +  if (!zero_type(indentation_width)) { +  indentation = sprintf("%"+indentation_width+"n"); +  }       // create table eventlog (event int unsigned auto_increment primary key,    // at timestamp not null, code int unsigned not null, extra varchar(255))       Sql.Sql db = get_db();       if(catch(db->query("SELECT code FROM eventlog WHERE event=0")))    db->query("CREATE TABLE eventlog ("    "event int unsigned auto_increment primary key,"    "at timestamp not null,"
pike.git/lib/modules/Search.pmod/Utils.pmod:709:    "type enum('error','warning','notice') not null,"    "extra varchar(255))");    }       void werror_event( int code, string type, void|string extra, void|int log_profile )    {    mapping types = ([ "error" : "Error",    "warning" : "Warning",    "notice" : "Notice", ]);    -  werror(sprintf("%sSearch: %s: %s\n", -  " : ", +  werror(sprintf("%s: Search: %s: %s\n", +  indentation,    types[type],    extra?sprintf(codes[(int)code], @(extra/"\n")):codes[(int)code]));    }       void log_purge(int days)    {    Sql.Sql db = get_db();    if(!db) return;    int t1 = time();    if (t1 < last_log_purge_time + log_purge_freq) return;