#include "split.h"
#include <glib/gmessages.h>
#include "captive/macros.h"
+#include <libxml/tree.h>
+#include "../client/vfs-parent.h"
static void impl_Captive_GLogFunc_g_log_func
};
-Captive_GLogFunc impl_Captive_GLogFunc__create(PortableServer_POA poa,CORBA_Environment *ev)
+Captive_GLogFunc impl_Captive_GLogFunc__create
+ (PortableServer_POA poa,CaptiveVfsParentObject *captive_vfs_parent_object,CORBA_Environment *ev)
{
Captive_GLogFunc retval;
impl_POA_Captive_GLogFunc *newservant;
captive_new0(newservant); /* FIXME: leak */
newservant->servant.vepv=&impl_Captive_GLogFunc_vepv;
newservant->poa=poa;
+ newservant->captive_vfs_parent_object=captive_vfs_parent_object;
POA_Captive_GLogFunc__init((PortableServer_Servant)newservant,ev);
objid=PortableServer_POA_activate_object(poa,newservant,ev);
CORBA_free(objid);
(impl_POA_Captive_GLogFunc *servant,const Captive_GLogMessage *g_log_message,CORBA_Environment *ev)
{
GLogLevelFlags log_level_use;
-gboolean fatal=FALSE;
-
- log_level_use=g_log_message->log_level;
- /* Downgrade always-fatal 'ERROR' to 'CRITICAL' level */
- if (log_level_use&G_LOG_LEVEL_ERROR) {
- log_level_use=(log_level_use|G_LOG_LEVEL_CRITICAL)&~G_LOG_LEVEL_ERROR;
- fatal=TRUE;
- }
- if (log_level_use&G_LOG_FLAG_FATAL) {
- log_level_use&=~G_LOG_FLAG_FATAL;
- fatal=TRUE;
+static const struct level_map {
+ GLogLevelFlags from,to;
+ const gchar *name;
+ } level_map[]={
+ /* Downgrade always-fatal 'ERROR' to 'CRITICAL' level */
+ { G_LOG_LEVEL_ERROR ,G_LOG_LEVEL_CRITICAL,"error" },
+ { G_LOG_LEVEL_CRITICAL,G_LOG_LEVEL_CRITICAL,"critical" },
+ { G_LOG_LEVEL_WARNING ,G_LOG_LEVEL_WARNING ,"warning" },
+ { G_LOG_LEVEL_MESSAGE ,G_LOG_LEVEL_MESSAGE ,"message" },
+ { G_LOG_LEVEL_INFO ,G_LOG_LEVEL_INFO ,"info" },
+ { G_LOG_LEVEL_DEBUG ,G_LOG_LEVEL_DEBUG ,"debug" },
+ };
+static const struct flag_map {
+ GLogLevelFlags from,to;
+ const gchar *name;
+ } flag_map[]={
+ { G_LOG_FLAG_RECURSION,G_LOG_FLAG_RECURSION,"recursion" },
+ { G_LOG_FLAG_FATAL ,0 ,"fatal" },
+ };
+const struct level_map *levelp;
+const struct flag_map *flagp;
+
+ for (levelp=level_map;levelp<level_map+G_N_ELEMENTS(level_map);levelp++) {
+ log_level_use=g_log_message->log_level;
+ if (!(g_log_message->log_level & levelp->from))
+ continue;
+ {
+ xmlNode *xml_message=NULL;
+
+ if (servant->captive_vfs_parent_object->corba_bug_log) {
+ xml_message=xmlNewTextChild(servant->captive_vfs_parent_object->corba_bug_log,NULL,BAD_CAST "message",BAD_CAST g_log_message->message);
+ xmlNewProp(xml_message,BAD_CAST "level",BAD_CAST levelp->name);
+ }
+
+ log_level_use&=~levelp->from;
+ log_level_use|= levelp->to;
+ for (flagp=flag_map;flagp<flag_map+G_N_ELEMENTS(flag_map);flagp++) {
+ if (!(g_log_message->log_level & flagp->from))
+ continue;
+ log_level_use&=~flagp->from;
+ log_level_use|= flagp->to;
+ if (xml_message)
+ xmlNewProp(xml_message,BAD_CAST flagp->name,BAD_CAST flagp->name);
+ }
+ }
+ g_log(G_LOG_DOMAIN,log_level_use,"sandbox: %s%s",
+ (!(g_log_message->log_level & G_LOG_FLAG_FATAL) ? "" : "FATAL: "),
+ g_log_message->message);
}
-
- g_log(G_LOG_DOMAIN,log_level_use,"sandbox: %s%s",(!fatal ? "" : "FATAL: "),g_log_message->message);
}
/* The same mask is in:
* libcaptive/sandbox/server-GLogFunc.c
* libcaptive/client/init.c
- * libcaptive/client/vfs.c
*/
| G_LOG_LEVEL_MESSAGE
| G_LOG_LEVEL_INFO