moved kdeaccessibility kdeaddons kdeadmin kdeartwork kdebindings kdeedu kdegames...
[kdeedu.git] / kstars / kstars / indi / fli / libfli-debug.c
blob203274b3e6740c7dcc900e28897777c278d50dfc
1 /*
3 Copyright (c) 2002 Finger Lakes Instrumentation (FLI), L.L.C.
4 All rights reserved.
6 Redistribution and use in source and binary forms, with or without
7 modification, are permitted provided that the following conditions
8 are met:
10 Redistributions of source code must retain the above copyright
11 notice, this list of conditions and the following disclaimer.
13 Redistributions in binary form must reproduce the above
14 copyright notice, this list of conditions and the following
15 disclaimer in the documentation and/or other materials
16 provided with the distribution.
18 Neither the name of Finger Lakes Instrumentation (FLI), LLC
19 nor the names of its contributors may be used to endorse or
20 promote products derived from this software without specific
21 prior written permission.
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 POSSIBILITY OF SUCH DAMAGE.
36 ======================================================================
38 Finger Lakes Instrumentation, L.L.C. (FLI)
39 web: http://www.fli-cam.com
40 email: support@fli-cam.com
44 #include <syslog.h>
45 #include <stdarg.h>
47 #include "libfli-libfli.h"
49 int sysloglevel(int level)
51 switch (level)
53 case FLIDEBUG_INFO:
54 return LOG_INFO;
55 break;
57 case FLIDEBUG_WARN:
58 return LOG_WARNING;
59 break;
61 case FLIDEBUG_FAIL:
62 return LOG_ERR;
63 break;
65 case FLIDEBUG_ALL:
66 return LOG_EMERG | LOG_ALERT | LOG_CRIT | LOG_ERR | LOG_WARNING |
67 LOG_NOTICE | LOG_INFO | LOG_DEBUG;
68 break;
71 return 0;
74 int debugopen(char *host)
76 openlog("libfli", LOG_PID , LOG_USER);
78 return 0;
81 int debugclose(void)
83 closelog();
85 return 0;
88 void debug(int level, const char *format, ...)
90 va_list ap;
92 va_start(ap, format);
93 vsyslog(sysloglevel(level), format, ap);
94 va_end(ap);
96 return;
100 void setdebuglevel(char *host, int level)
102 static int open = 0;
104 if (level == 0)
106 debugclose();
107 open = 0;
108 return;
111 if (open == 0)
113 debugopen(host);
114 open = 1;
117 setlogmask(LOG_UPTO(sysloglevel(level)));
119 return;