~ubuntu-branches/ubuntu/wily/telepathy-glib/wily

« back to all changes in this revision

Viewing changes to telepathy-glib/debug.c

  • Committer: Bazaar Package Importer
  • Author(s): Simon McVittie
  • Date: 2009-03-24 22:06:52 UTC
  • mfrom: (1.3.1 upstream) (17.1.10 sid)
  • Revision ID: james.westby@ubuntu.com-20090324220652-c8dvom0nsqomp23d
Tags: 0.7.28-1
* New upstream version (ABI, API added)
* Put the -dbg package in section debug, as per recent archive changes
* Remove obsolete Conflicts/Replaces with libtelepathy-glib-static-dev, which
  was never in a stable release (and probably never in Debian at all)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 * telepathy-glib has an internal mechanism for debug messages and filtering.
27
27
 * Connection managers written with telepathy-glib are expected to connect
28
28
 * this to their own debugging mechanisms: when the CM's debugging mechanism
29
 
 * is activated, it should call tp_debug_set_flags_from_string(),
30
 
 * tp_debug_set_flags_from_env() or tp_debug_set_all_flags().
 
29
 * is activated, it should call tp_debug_set_flags() and/or
 
30
 * tp_debug_set_persistent().
31
31
 *
32
 
 * The supported debug-mode keywords are subject to change, but currently
33
 
 * include:
 
32
 * The supported debug-mode keywords and the debug messages that they enable
 
33
 * are subject to change, but currently include:
34
34
 *
35
35
 * <itemizedlist>
36
 
 * <listitem><literal>manager</literal> - output debug messages regarding
37
 
 * #TpConnectionManager (client)</listitem>
38
 
 * <listitem><literal>connection</literal> - output debug messages regarding
39
 
 * #TpBaseConnection (service) and #TpConnection (client)</listitem>
40
 
 * <listitem><literal>channel</literal> - output debug messages regarding
41
 
 * #TpChannel (client)</listitem>
42
 
 * <listitem><literal>im</literal> - output debug messages regarding
43
 
 * (text) instant messaging (service)</listitem>
44
 
 * <listitem><literal>properties</literal> - output debug messages regarding
45
 
 * #TpPropertiesMixin (service)</listitem>
46
 
 * <listitem><literal>params</literal> - output debug messages regarding
47
 
 * connection manager parameters (service)</listitem>
 
36
 * <listitem><literal>manager</literal> -
 
37
 *    #TpConnectionManager (client)</listitem>
 
38
 * <listitem><literal>connection</literal> - #TpBaseConnection (service)
 
39
 *    and #TpConnection (client)</listitem>
 
40
 * <listitem><literal>contacts</literal> - #TpContact objects
 
41
 *    (client)</listitem>
 
42
 * <listitem><literal>channel</literal> - #TpChannel (client)</listitem>
 
43
 * <listitem><literal>im</literal> - (text) instant messaging
 
44
 *    (service)</listitem>
 
45
 * <listitem><literal>properties</literal> -
 
46
 *    #TpPropertiesMixin (service)</listitem>
 
47
 * <listitem><literal>params</literal> - connection manager parameters
 
48
 *    (service)</listitem>
 
49
 * <listitem><literal>handles</literal> - handle reference tracking tracking
 
50
 *    in #TpBaseConnection (service) and #TpConnection (client)</listitem>
48
51
 * <listitem><literal>all</literal> - all of the above</listitem>
49
52
 * </itemizedlist>
50
53
 */
54
57
#include <fcntl.h>
55
58
#include <stdarg.h>
56
59
#include <sys/stat.h>
 
60
 
 
61
#ifdef HAVE_UNISTD_H
57
62
#include <unistd.h>
 
63
#endif
58
64
 
59
65
#include <glib.h>
60
66
#include <glib/gstdio.h>
98
104
  { "manager",       TP_DEBUG_MANAGER },
99
105
  { "channel",       TP_DEBUG_CHANNEL },
100
106
  { "proxy",         TP_DEBUG_PROXY },
 
107
  { "handles",       TP_DEBUG_HANDLES },
 
108
  { "contacts",      TP_DEBUG_CONTACTS },
101
109
  { 0, }
102
110
};
103
111
 
299
307
 * stdout and stderr, and sending all messages that would have gone there
300
308
 * to the given file instead.
301
309
 *
 
310
 * By default the file is truncated and hence overwritten each time the
 
311
 * process is executed.
 
312
 * Since version 0.7.14, if the filename is prefixed with '+' then the
 
313
 * file is not truncated and output is added at the end of the file.
 
314
 *
302
315
 * Passing %NULL to this function is guaranteed to have no effect. This is
303
316
 * so you can call it with the recommended usage
304
317
 * <literal>tp_debug_divert_messages (g_getenv ("MYAPP_LOGFILE"))</literal>
317
330
  if (filename == NULL)
318
331
    return;
319
332
 
320
 
  fd = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 
333
  if (filename[0] == '+')
 
334
    {
 
335
      /* open in append mode */
 
336
      fd = g_open (filename + 1, O_WRONLY | O_CREAT | O_APPEND, 0644);
 
337
    }
 
338
  else
 
339
    {
 
340
      /* open in trunc mode */
 
341
      fd = g_open (filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
 
342
    }
321
343
 
322
344
  if (fd == -1)
323
345
    {