Changeset f511c1e


Ignore:
Timestamp:
Jan 7, 2014, 6:00:47 PM (8 years ago)
Author:
Jason Gross <jgross@mit.edu>
Children:
6e764aa
Parents:
e38cc20
git-author:
Jason Gross <jgross@mit.edu> (07/12/11 15:23:27)
git-committer:
Jason Gross <jgross@mit.edu> (01/07/14 18:00:47)
Message:
Moved outgoing zephyr error logging to perl
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • logging.c

    rdca6255 rf511c1e  
    128128void owl_log_outgoing_zephyr_error(const owl_zwrite *zw, const char *text)
    129129{
    130   char *filename, *logpath;
    131   char *tobuff, *recip;
    132130  owl_message *m;
    133   GString *msgbuf;
    134131  /* create a present message so we can pass it to
    135132   * owl_log_shouldlog_message(void)
     
    142139    return;
    143140  }
     141  char *buffer = owl_perlconfig_message_call_method(m, "log_outgoing_error", 0, NULL);
     142  char *filenames_string = owl_perlconfig_call_with_message("BarnOwl::Logging::get_filenames_as_string", m);
     143  char **filenames = g_strsplit(filenames_string, " ", 0);
     144  char **filename_ptr;
     145
     146  for (filename_ptr = filenames; *filename_ptr != NULL; filename_ptr++) {
     147    owl_log_enqueue_message(buffer, *filename_ptr);
     148  }
     149
     150  g_free(filenames_string);
     151  g_strfreev(filenames);
    144152  owl_message_delete(m);
    145 
    146   /* chop off a local realm */
    147   recip = owl_zwrite_get_recip_n_with_realm(zw, 0);
    148   tobuff = short_zuser(recip);
    149   g_free(recip);
    150 
    151   /* expand ~ in path names */
    152   logpath = owl_util_makepath(owl_global_get_logpath(&g));
    153   filename = g_build_filename(logpath, tobuff, NULL);
    154   msgbuf = g_string_new("");
    155   g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);
    156   if (text[strlen(text)-1] != '\n') {
    157     g_string_append_printf(msgbuf, "\n");
    158   }
    159   owl_log_enqueue_message(msgbuf->str, filename);
    160   g_string_free(msgbuf, TRUE);
    161 
    162   filename = g_build_filename(logpath, "all", NULL);
    163   g_free(logpath);
    164   msgbuf = g_string_new("");
    165   g_string_printf(msgbuf, "ERROR (owl): %s\n%s\n", tobuff, text);
    166   if (text[strlen(text)-1] != '\n') {
    167     g_string_append_printf(msgbuf, "\n");
    168   }
    169   owl_log_enqueue_message(msgbuf->str, filename);
    170   g_string_free(msgbuf, TRUE);
    171 
    172   g_free(tobuff);
    173153}
    174154
  • perl/lib/BarnOwl/Message.pm

    rdca6255 rf511c1e  
    210210sub log_base_path {
    211211    return BarnOwl::getvar('logpath');
     212}
     213
     214=head2 log_outgoing_error MESSAGE
     215
     216Returns the string that should be logged if there is an error sending
     217an outgoing message.
     218
     219=cut
     220
     221sub log_outgoing_error {
     222    my ($m) = @_;
     223    my $recipient = $m->pretty_recipient;
     224    my $body = $m->body;
     225    chomp $body;
     226    return "ERROR (BarnOwl): $recipient\n$body\n\n";
    212227}
    213228
Note: See TracChangeset for help on using the changeset viewer.