[MOD] Verbosity levels, avatar cleanser

I have a weird bug where Parsee seems to hang on a Db request, been
tryign to figure that otu since a while but can't quite put my finger on
where.
You can have this commit, as a treat.
This commit is contained in:
LDA 2024-08-24 19:36:37 +02:00
commit 692cb8aa6f
19 changed files with 190 additions and 111 deletions

View file

@ -43,7 +43,10 @@ static const Argument arguments[] =
Arg('C', true, "file(='parsee.json')", "Sets the JSON config to use")
Arg('g', false, NULL,"Generates a parsee.yaml AS file before exiting")
Arg('v', false, NULL,"Forces Parsee to print in a more verbose fashion")
Arg('v', false, NULL,
"Forces Parsee to print in a more verbose fashion "
"(-vv prints stanzas to stderr)"
)
Arg('h', false, NULL,"Generates an help screen(this one!)")
EndOfArgs
@ -63,6 +66,7 @@ Main(Array *args, HashMap *env)
char *configuration = "parsee.json";
int xmpp = 8;
int http = 8;
int verbose = 0;
start = UtilTsMillis();
@ -78,10 +82,7 @@ Main(Array *args, HashMap *env)
ArgParseState state;
char *opts = ParseeGenerateGetopt(arguments);
int flag;
ArgParseStateInit(&state);
/* TODO: Have a smarter way of generating the arg table
* (with a list of structs, with a description and everything) */
while ((flag = ArgParse(&state, args, opts)) != -1)
{
switch (flag)
@ -105,7 +106,26 @@ Main(Array *args, HashMap *env)
Free(opts);
goto end;
case 'v':
LogConfigLevelSet(LogConfigGlobal(), LOG_DEBUG);
switch (++verbose)
{
case PARSEE_VERBOSE_LOG:
LogConfigLevelSet(LogConfigGlobal(), LOG_DEBUG);
break;
case PARSEE_VERBOSE_STANZA:
Log(LOG_DEBUG, "Enabling stanza printing.");
break;
case PARSEE_VERBOSE_COMICAL:
Log(LOG_DEBUG, "What?");
Log(LOG_DEBUG, "No, but like, what do you except?");
Log(LOG_DEBUG, "Like do you want to log _every_ instruction?");
Log(LOG_DEBUG, "Like just every single thing %s does?", NAME);
Log(LOG_DEBUG, " ( why??? )");
Log(LOG_DEBUG, ".....................................");
Log(LOG_DEBUG, "Argh.");
Log(LOG_DEBUG, "Alright. I'll do my best.");
Log(LOG_DEBUG, "Get what you paid for.");
break;
}
break;
case 'C':
if (!UtilLastModified(state.optArg))
@ -126,6 +146,10 @@ Main(Array *args, HashMap *env)
ParseeSetThreads(xmpp, http);
}
if (verbose >= PARSEE_VERBOSE_COMICAL)
{
Log(LOG_DEBUG, "Loading configuration...");
}
ParseeConfigLoad(configuration);
ParseeConfigInit();
parsee_conf = ParseeConfigGet();
@ -142,14 +166,38 @@ Main(Array *args, HashMap *env)
))
{
Log(LOG_ERR, "Could not connect to XMPP...");
if (verbose >= PARSEE_VERBOSE_COMICAL)
{
Log(LOG_DEBUG, "Destroying component...");
}
XMPPEndCompStream(jabber);
goto end;
}
Log(LOG_NOTICE, "Creating volatile tables...");
if (verbose >= PARSEE_VERBOSE_COMICAL)
{
Log(LOG_DEBUG, "Initialising JID table");
}
ParseeInitialiseJIDTable();
if (verbose >= PARSEE_VERBOSE_COMICAL)
{
Log(LOG_DEBUG, "Initialising OID table");
}
ParseeInitialiseOIDTable();
if (verbose >= PARSEE_VERBOSE_COMICAL)
{
Log(LOG_DEBUG, "Initialising head table");
}
ParseeInitialiseHeadTable();
if (verbose >= PARSEE_VERBOSE_COMICAL)
{
Log(LOG_DEBUG, "Initialising nick table");
}
ParseeInitialiseNickTable();
conf.port = parsee_conf->port;
@ -158,6 +206,9 @@ Main(Array *args, HashMap *env)
conf.handlerArgs = ParseeInitData(jabber);
conf.handler = ParseeRequest;
Log(LOG_DEBUG, "Verbosity level: %d", verbose);
((ParseeData *) conf.handlerArgs)->verbosity = verbose;
Log(LOG_NOTICE, "Setting up local Matrix user...");
if (ASRegisterUser(parsee_conf, parsee_conf->sender_localpart))
{