d0692e75ac9177cc40c50b7450c046f9aced049f
[public/netxms.git] / src / db / libnxdb / main.cpp
1 /*
2 ** NetXMS - Network Management System
3 ** Database Abstraction Library
4 ** Copyright (C) 2003-2016 Victor Kirhenshtein
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU Lesser 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 General Public License for more details.
15 **
16 ** You should have received a copy of the GNU Lesser General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **
20 ** File: main.cpp
21 **
22 **/
23
24 #include "libnxdb.h"
25
26 /**
27 * Write log
28 */
29 void __DBWriteLog(WORD level, const TCHAR *format, ...)
30 {
31 TCHAR buffer[4096];
32 va_list args;
33
34 va_start(args, format);
35 _vsntprintf(buffer, 4096, format, args);
36 va_end(args);
37 nxlog_write(g_logMsgCode, level, "s", buffer);
38 }
39
40 /**
41 * Set long running query threshold (milliseconds)
42 */
43 void LIBNXDB_EXPORTABLE DBSetLongRunningThreshold(UINT32 threshold)
44 {
45 g_sqlQueryExecTimeThreshold = threshold;
46 nxlog_debug(3, _T("DB Library: long running query threshold set to %u"), threshold);
47 }
48
49 #ifdef _WIN32
50
51 /**
52 * DLL entry point
53 */
54 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
55 {
56 if (dwReason == DLL_PROCESS_ATTACH)
57 DisableThreadLibraryCalls(hInstance);
58 return TRUE;
59 }
60
61 #endif /* _WIN32 */