/[pdpsoft]/trunk/grid-mw-security/ees/src/eef/eef_log.c
ViewVC logotype

Contents of /trunk/grid-mw-security/ees/src/eef/eef_log.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1121 - (show annotations) (download) (as text)
Fri Nov 13 14:11:05 2009 UTC (12 years, 8 months ago) by aramv
File MIME type: text/x-chdr
File size: 1742 byte(s)
Fixed duplicate symbol bug
1 #include "eef_log.h"
2 FILE* log_file_fp;
3
4 EES_RC eef_log(int priority, char* format, ...){
5 va_list args;
6 /*time_t _time;*/
7 /*struct tm * _time_s;*/
8 /*char _strf_fmt[MAX_TIME_STRING_SIZE];*/
9
10 /*_time = time(NULL);*/
11 /*_time_s = localtime(&_time);*/
12 /*strftime(_strf_fmt, MAX_TIME_STRING_SIZE, "%G", _time_s);*/
13 char *_format = append_newline(format);
14
15 /* worst case scenario logging */
16 va_start(args, format);
17 if((priority == LOG_ERR) || (priority == LOG_WARNING)){
18 vfprintf(stderr, _format, args);
19 }
20 va_end(args);
21
22 /* debug logging */
23 #if ENABLE_DEBUG
24 va_start(args, format);
25 if(priority == LOG_DEBUG){
26 vfprintf(stderr, _format, args);
27 }
28 va_end(args);
29 #endif
30
31 /* if the format string was changed by appending, it needs to be free'd */
32 if(format != _format){
33 free(_format);
34 }
35 _format = strip_newline(format);
36
37 /* Default output */
38 va_start(args, format);
39 if(log_file_fp == NULL){
40 vsyslog(priority, _format, args);
41 } else {
42 vfprintf(log_file_fp, _format, args);
43 }
44 va_end(args);
45
46 /* if the format string was changed by stripping, it needs to be free'd */
47 if(format != _format){
48 free(_format);
49 }
50 return 0;
51 }
52
53 char* append_newline(char* string){
54 char* mutable_string = NULL;
55 size_t string_length = strlen(string);
56
57 if(string[strlen(string)-1] != '\n'){
58 if((mutable_string = calloc((string_length+2),sizeof(char)))){
59 strncpy(mutable_string, string, string_length);
60 strncat(mutable_string, "\n", 1);
61 return mutable_string;
62 }
63 }
64 return string;
65 }
66
67 char* strip_newline(char* string){
68 /*char* mutable_string = NULL;*/
69 /*size_t string_length = strlen(string);*/
70
71 /* TODO */
72
73 return string;
74 }

Properties

Name Value
svn:mergeinfo

grid.support@nikhef.nl
ViewVC Help
Powered by ViewVC 1.1.28