1 /* Copyright (c) 2011, 2021, Oracle and/or its affiliates.
2 
3    This program is free software; you can redistribute it and/or modify
4    it under the terms of the GNU General Public License, version 2.0,
5    as published by the Free Software Foundation.
6 
7    This program is also distributed with certain software (including
8    but not limited to OpenSSL) that is licensed under separate terms,
9    as designated in a particular file or component or in included license
10    documentation.  The authors of MySQL hereby grant you an additional
11    permission to link the program and your derivative works with the
12    separately licensed software that they have included with MySQL.
13 
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License, version 2.0, for more details.
18 
19    You should have received a copy of the GNU General Public License
20    along with this program; if not, write to the Free Software
21    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA */
22 
23 #include <my_global.h>
24 #include "common.h"
25 
26 
27 // Client-side logging function
28 
error_log_vprint(error_log_level::type level,const char * fmt,va_list args)29 void error_log_vprint(error_log_level::type level,
30                         const char *fmt, va_list args)
31 {
32   const char *level_string= "";
33   int   log_level= get_log_level();
34 
35   switch (level)
36   {
37   case error_log_level::INFO:
38     if (3 > log_level)
39       return;
40     level_string= "Note";
41     break;
42   case error_log_level::WARNING:
43     if (2 > log_level)
44       return;
45     level_string= "Warning";
46     break;
47   case error_log_level::ERROR:
48     if (1 > log_level)
49       return;
50     level_string= "ERROR";
51     break;
52   }
53 
54   fprintf(stderr, "Windows Authentication Plugin %s: ", level_string);
55   vfprintf(stderr, fmt, args);
56   fputc('\n', stderr);
57   fflush(stderr);
58 }
59 
60 
61 // Trivial implementation of log-level setting storage.
62 
set_log_level(unsigned int level)63 void set_log_level(unsigned int level)
64 {
65   opt_auth_win_log_level= level;
66 }
67 
68 
get_log_level(void)69 unsigned int  get_log_level(void)
70 {
71   return opt_auth_win_log_level;
72 }
73