Update Iot.js
[platform/upstream/iotjs.git] / tools / docs / devs / Logging-IoT.js-execution.md
1 ### Logging Support
2
3 IoT.js supports logging on Debug version. It can output message strings to the stderr console by default or any file you give.
4
5 To add a message line, use one of three macros in the source, defined in iotjs_module_debug.h
6 ```
7 DLOG()
8 DDLOG()
9 DDDLOG()
10 ```
11 DLOG is level 1 which means it's an error so that should be displayed. DDLOG is for warning messages and is level 2. DDDLOG is information you need while IoT.js is running, which is level 3. Default is 1.
12
13 ### Setting logging level
14
15 In linux, use `IOTJS_DEBUG_LEVEL` environment variable to change the level, for example, if you want to see error and warning messages;
16 ```
17 export IOTJS_DEBUG_LEVEL=2
18 ```
19 Numbers can be 0, 1, 2 or 3. If you give 0, it will be silence, no message.
20
21 ### Logging to a file
22
23 To save to a file, use also the environment variable, for example;
24 ```
25 export IOTJS_DEBUG_LOGFILE="/home/iotjsdev/iotjslog.txt"
26 ```
27 You must have file creation rights to that directory. File will be overwritten on every start, so don't run the program before looking inside or backing it up.
28
29 To disable logging to a file,
30 ```
31 unset IOTJS_DEBUG_LOGFILE
32 ```
33 will do.