Changeset c877a63 for logging.c


Ignore:
Timestamp:
Jan 7, 2014, 6:00:45 PM (9 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
e7ab1d7
Parents:
db1a2f8b
git-author:
Jason Gross <jgross@mit.edu> (07/12/11 12:34:46)
git-committer:
Jason Gross <jgross@mit.edu> (01/07/14 18:00:45)
Message:
Moved log generation code to perl.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    rdb1a2f8b rc877a63  
    7777}
    7878
    79 CALLER_OWN char *owl_log_zephyr(const owl_message *m)
    80 {
    81     char *tmp = NULL;
    82     GString *buffer = NULL;
    83     buffer = g_string_new("");
    84     tmp = short_zuser(owl_message_get_sender(m));
    85     g_string_append_printf(buffer, "Class: %s Instance: %s",
    86                            owl_message_get_class(m),
    87                            owl_message_get_instance(m));
    88     if (strcmp(owl_message_get_opcode(m), "")) {
    89       g_string_append_printf(buffer, " Opcode: %s",
    90                              owl_message_get_opcode(m));
    91     }
    92     g_string_append_printf(buffer, "\n");
    93     g_string_append_printf(buffer, "Time: %s Host: %s\n",
    94                            owl_message_get_timestr(m),
    95                            owl_message_get_hostname(m));
    96     g_string_append_printf(buffer, "From: %s <%s>\n\n",
    97                            owl_message_get_zsig(m), tmp);
    98     g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m));
    99     g_free(tmp);
    100     return g_string_free(buffer, FALSE);
    101 }
    102 
    103 CALLER_OWN char *owl_log_aim(const owl_message *m)
    104 {
    105     GString *buffer = NULL;
    106     buffer = g_string_new("");
    107     g_string_append_printf(buffer, "From: <%s> To: <%s>\n",
    108                            owl_message_get_sender(m), owl_message_get_recipient(m));
    109     g_string_append_printf(buffer, "Time: %s\n\n",
    110                            owl_message_get_timestr(m));
    111     if (owl_message_is_login(m)) {
    112         g_string_append_printf(buffer, "LOGIN\n\n");
    113     } else if (owl_message_is_logout(m)) {
    114         g_string_append_printf(buffer, "LOGOUT\n\n");
    115     } else {
    116         g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m));
    117     }
    118     return g_string_free(buffer, FALSE);
    119 }
    120 
    121 CALLER_OWN char *owl_log_jabber(const owl_message *m)
    122 {
    123     GString *buffer = NULL;
    124     buffer = g_string_new("");
    125     g_string_append_printf(buffer, "From: <%s> To: <%s>\n",
    126                            owl_message_get_sender(m),
    127                            owl_message_get_recipient(m));
    128     g_string_append_printf(buffer, "Time: %s\n\n",
    129                            owl_message_get_timestr(m));
    130     g_string_append_printf(buffer, "%s\n\n", owl_message_get_body(m));
    131     return g_string_free(buffer, FALSE);
    132 }
    133 
    134 CALLER_OWN char *owl_log_generic(const owl_message *m)
    135 {
    136     GString *buffer;
    137     buffer = g_string_new("");
    138     g_string_append_printf(buffer, "From: <%s> To: <%s>\n",
    139                            owl_message_get_sender(m),
    140                            owl_message_get_recipient(m));
    141     g_string_append_printf(buffer, "Time: %s\n\n",
    142                            owl_message_get_timestr(m));
    143     g_string_append_printf(buffer, "%s\n\n",
    144                            owl_message_get_body(m));
    145     return g_string_free(buffer, FALSE);
    146 }
    147 
    14879static void owl_log_error_main_thread(gpointer data)
    14980{
     
    198129
    199130void owl_log_append(const owl_message *m, const char *filename) {
    200   char *buffer = NULL;
    201   if (owl_message_is_type_zephyr(m)) {
    202     buffer = owl_log_zephyr(m);
    203   } else if (owl_message_is_type_jabber(m)) {
    204     buffer = owl_log_jabber(m);
    205   } else if (owl_message_is_type_aim(m)) {
    206     buffer = owl_log_aim(m);
    207   } else {
    208     buffer = owl_log_generic(m);
    209   }
     131  char *buffer = owl_perlconfig_message_call_method(m, "log", 0, NULL);
    210132  owl_log_enqueue_message(buffer, filename);
    211133  g_free(buffer);
Note: See TracChangeset for help on using the changeset viewer.