summaryrefslogtreecommitdiffstats
path: root/docs/nspr/reference/nspr_log_modules.rst
blob: 9f2986607f62a095ccdd6c806a677270838f9350 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
NSPR_LOG_MODULES
================

This environment variable specifies which log modules have logging
enabled.


Syntax
------

::

   moduleName:level[, moduleName:level]*

*moduleName* is the name specified in a
`:ref:`PR_NewLogModule` <http://www-archive.mozilla.org/projects/nspr/reference/html/prlog.html#25372>`__
call or one of the handy magic names listed below.

*level* is a numeric value between 0 and 5, with the values having the
following meanings:

-  0 = PR_LOG_NONE: nothing should be logged
-  1 = PR_LOG_ALWAYS: important; intended to always be logged
-  2 = PR_LOG_ERROR: errors
-  3 = PR_LOG_WARNING: warnings
-  4 = PR_LOG_DEBUG: debug messages, notices
-  5: everything!


Description
-----------

Specify a ``moduleName`` that is associated with the ``name`` argument
in a call to
`:ref:`PR_NewLogModule` <http://www-archive.mozilla.org/projects/nspr/reference/html/prlog.html#25372>`__
and a non-zero ``level`` value to enable logging for the named
``moduleName``.

Special log module names are provided for controlling NSPR's log service
at execution time. These controls should be set in the
:ref:`NSPR_LOG_MODULES` environment variable at execution time to affect
NSPR's log service for your application.

-  **all** The name ``all`` enables all log modules. To enable all log
   module calls to
   ```PR_LOG`` <http://www-archive.mozilla.org/projects/nspr/reference/html/prlog.html#25497>`__,
   set the variable as follows:

   ::

      set NSPR_LOG_MODULES=all:5

-  **timestamp** Including ``timestamp`` results in a timestamp of the
   form "2015-01-15 21:24:26.049906 UTC - " prefixing every logged line.

-  **append** Including ``append`` results in log entries being appended
   to the existing contents of the file referenced by NSPR_LOG_FILE.  If
   not specified, the existing contents of NSPR_LOG_FILE will be lost as
   a new file is created with the same filename.

-  **sync** The name ``sync`` enables unbuffered logging.   This ensures
   that all log messages are flushed to the operating system as they are
   written, but may slow the program down.

-  **bufsize:size** The name ``bufsize:``\ *size* sets the log buffer to
   *size*.

Examples
--------

Log everything from the Toolkit::Storage component that happens,
prefixing each line with the timestamp when it was logged to the file
/tmp/foo.log (which will be replaced each time the executable is run).

::

   set NSPR_LOG_MODULES=timestamp,mozStorage:5
   set NSPR_LOG_FILE=/tmp/foo.log

.. _Logging_with_Try_Server:

Logging with Try Server
-----------------------

-  For **mochitest**, edit variable :ref:`NSPR_LOG_MODULES` in
   ``testing/mochitest/runtests.py`` before pushing to try. You would be
   able to download the log file as an artifact from the Log viewer.
-  (other tests?)