Statistics
| Branch: | Revision:

peerstreamer-src / src / debug.c @ 58fb2cdc

History | View | Annotate | Download (1.32 KB)

1 9eb656e7 Luca Baldesi
/*******************************************************************
2
* PeerStreamer-ng is a P2P video streaming application exposing a ReST
3
* interface.
4
* Copyright (C) 2017 Luca Baldesi <luca.baldesi@unitn.it>
5
*
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU Affero General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
* GNU Affero General Public License for more details.
15
*
16
* You should have received a copy of the GNU Affero General Public License
17
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
*******************************************************************/
19
20
#include<debug.h>
21
#include<stdarg.h>
22
#include<stdio.h>
23
24
static uint8_t debug_on;
25
26 91e9f1a7 Luca Baldesi
void info(char *msg, ...)
27
{
28
        va_list argp;
29
30
        if(debug_on >= 1)
31
        {
32
                va_start(argp, msg);
33
                vfprintf(stderr, msg, argp);
34
                va_end(argp);
35
        }
36
}
37
38 9eb656e7 Luca Baldesi
void debug(char *msg, ...)
39
{
40
        va_list argp;
41
42 91e9f1a7 Luca Baldesi
        if(debug_on >= 2)
43 9eb656e7 Luca Baldesi
        {
44
                va_start(argp, msg);
45 59457bd3 Luca Baldesi
                vfprintf(stderr, msg, argp);
46 9eb656e7 Luca Baldesi
                va_end(argp);
47
        }
48
}
49
50
void set_debug(uint8_t set)
51
{
52
        debug_on = set;
53
}