/* This file is part of Bolixo. Bolixo is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Bolixo is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Bolixo. If not, see . */ /* This program process the logs produced by bo-writed. The logs are meant to allow synchronisation of a failover server. Everything written by bo-writed in the databases is going in the log (not complete for now). */ #include #include #include #include #include #include #include "bolixo.m" using namespace std; #include #include "proto/bo-log.protoh" static void print_to(const char *varname, const vector &to) { printf ("%s=[",varname); const char *prefix = ""; for (auto &t:to){ printf ("%s%s",prefix,t); prefix = ","; } printf ("]"); } static void print_stamp(long long timestamp) { time_t seconds = timestamp/1000000; struct tm *t = localtime(&seconds); printf ("%4d/%02d/%02d %02d:%02d:%02d %6Ld",t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec,timestamp%1000000); } int main (int argc, char *argv[]) { glocal int ret = -1; glocal const char *logfile = nullptr; glocal bool extra = false; glocal.ret = (argc,argv,"bolixo"); setproginfo ("bo-log",VERSION,MSG_U(I_BO_LOG,"bo-writed log viewer")); setarg ('l',"logfile",MSG_U(I_LOGFILE,"bo-writed logfile"),glocal.logfile,true); setarg ('x',"extra",MSG_U(I_EXTRA,"Show all content"),glocal.extra,false); int ret = 0; FILE *fin = fopen (glocal.logfile,"r"); if (fin == nullptr){ tlmp_error (MSG_R(E_OPENFILE),glocal.logfile,strerror(errno)); fputs ("\n",stderr); exit (-1); } (fin); // userid name email password created:u print_stamp(timestamp); printf (" adduser userid=%s name=%s email=%s password=%s created=%u\n" ,userid,name,email,password,created); // userid confirmed:u print_stamp(timestamp); printf (" confirmuser userid=%s confirmed=%u\n",userid,confirmed); // userid deleteid print_stamp(timestamp); printf (" deleteuser userid=%s deleteid=%s\n",userid,deleteid); // userid deleteid print_stamp(timestamp); printf (" confirmdelete userid=%s deleteid=%s\n",userid,deleteid); // email on:b print_stamp(timestamp); printf (" makeadmin email=%s on=%d\n",email,on); // userid print_stamp(timestamp); printf (" del_incomplete userid=%s\n",userid); // to content:o more:b fileuuid print_stamp(timestamp); printf (" sendtalk_anon fileuuid=%s to=%s more=%d handle=%s\n",fileuuid,to,more,handle); // owner to:v groupname groupowner content:o more:b filename sign createdby fileuuid handle username print_stamp(timestamp); printf (" sendtalk fileuuid=%s username=%s owner=%s groupname=%s groupowner=%s content.size=%zu more=%d filename=%s createdby=%s handle=%s" ,fileuuid,username,owner,groupname,groupowner,content.getsize(),more,filename,createdby,handle); print_to (" to",to); printf ("\n"); if (glocal.extra){ auto tb = str_cnv2lines(sign); const char *prefix = "\tsign\t"; for (auto &l:tb){ printf ("%s%s\n",prefix,l.c_str()); prefix = "\t\t"; } printf ("\tcontent\t"); const char* pt = (const char *)content.getbuffer(); for (unsigned i=0; i // owner to:v groupname groupowner filename filedate fileuuid username print_stamp(timestamp); printf (" sendtalk_file fileuuid=%s username=%s owner=%s groupname=%s groupowner=%s filename=%s filedate=%s" ,fileuuid,username,owner,groupname,groupowner,filename,filedate); print_to (" to",to); printf ("\n"); // appendfile handle content:o more:b print_stamp(timestamp); printf (" appendfile handle=%s content.size()=%zu more=%d\n",handle,content.getsize(),more); if (glocal.extra){ printf ("\tcontent\t"); const char* pt = (const char *)content.getbuffer(); for (unsigned i=0; i // email nbfail print_stamp(timestamp); printf (" loginfail email=%s nbfail=%u\n",email,nbfail); // name print_stamp(timestamp); printf (" disableuser name=%s\n",name); // name print_stamp(timestamp); printf (" enableuser name=%s\n",name); printf ("Invalid line: %s\n",msg); fclose (fin); return ret; return glocal.ret; }