Added quantiling UDAFs
[com/gs-lite.git] / include / gslog.h
index 827af28..8ba314e 100644 (file)
- /*------------------------------------------------
-Copyright 2014 AT&T Intellectual Property
-   Licensed under the Apache License, Version 2.0 (the "License");
-   you may not use this file except in compliance with the License.
-   You may obtain a copy of the License at
-
-     http://www.apache.org/licenses/LICENSE-2.0
-
-   Unless required by applicable law or agreed to in writing, software
-   distributed under the License is distributed on an "AS IS" BASIS,
-   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-   See the License for the specific language governing permissions and
-   limitations under the License.
- ------------------------------------------- */
-
-/*
- * gslog.h: syslog wrappers for GS-lite
- */
-#ifndef GSLOG_H
-#define GSLOG_H
-
-
-#include "unistd.h"
-#include "sys/syslog.h"
-#include "stdio.h"
-#include "stdlib.h"
-#include "string.h"
-#include "stdarg.h"
-#include "time.h"
-#include "gsconfig.h"
-#include "gstypes.h"
-
-#ifdef LOGSTDERR
-static inline void gslog(int loglevel, const char * format, ...) {
-    va_list args;
-    va_start(args, format);
-    if (loglevel >= LOG_WARNING) {
-        vfprintf(stdout, format, args);
-        // Not generally syslog messages do not contain a \n so we need to add one for stdout/stderr
-        fprintf(stdout, "\n");
-        fflush(stdout);
-    } else {
-        //STDERR is not-buffered by default.
-        vfprintf(stderr, format, args);
-        fprintf(stderr, "\n");
-    }
-    va_end(args);
-}
-
-static inline void gsopenlog(gs_sp_t p) {
-    return;
-}
-
-#else
-
-#define gslog syslog
-
-#ifndef LOG_EMERG
-#define LOG_EMERG 7
-#endif
-
-// some state used for reporting
-
-extern gs_uint64_t intupledrop;
-extern gs_uint64_t outtupledrop;
-extern gs_uint64_t intuple;
-extern gs_uint64_t outtuple;
-extern gs_uint64_t inbytes;
-extern gs_uint64_t outbytes;
-extern gs_uint64_t cycles;
-
-
-static inline void gsopenlog(gs_sp_t p) {
-       gs_int8_t c[HOST_NAME_MAX+1];
-       gs_int8_t t[HOST_NAME_MAX+1+1000];
-       gs_sp_t t2;
-       if (gethostname(&c[0],HOST_NAME_MAX+1)!=0) {
-               fprintf(stderr,"GSCPV1::ERROR:could not get hostname\n");
-               exit(1);
-       }
-       c[HOST_NAME_MAX]=0;
-       sprintf(t,"GSCPv2:%s:%s:",c,p);
-       t2=strdup(t);
-       openlog(t2,LOG_NOWAIT|LOG_PID|LOG_CONS,LOG_LOCAL5);
-       gslog(LOG_INFO,"Started Logging");
-       intupledrop=0;
-       outtupledrop=0;
-       intuple=0;
-       outtuple=0;
-       inbytes=0;
-       outbytes=0;
-       cycles=0;
-}
-#endif
-
-static inline void gsstats() {
-       gs_uint32_t t;
-       //t=time(0);
-       //gslog(LOG_NOTICE,"STATS|%u|%llu|%llu|%llu|%llu|%llu|%llu|%llu",t,intuple,inbytes,intupledrop,outtuple,outbytes,outtupledrop,cycles);
-}
-
-#endif
+ /*------------------------------------------------\r
+Copyright 2014 AT&T Intellectual Property\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+     http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+ ------------------------------------------- */\r
+\r
+/*\r
+ * gslog.h: syslog wrappers for GS-lite\r
+ */\r
+#ifndef GSLOG_H\r
+#define GSLOG_H\r
+\r
+\r
+#include "unistd.h"\r
+#include "sys/syslog.h"\r
+#include "stdio.h"\r
+#include "stdlib.h"\r
+#include "string.h"\r
+#include "stdarg.h"\r
+#include "time.h"\r
+#include "gsconfig.h"\r
+#include "gstypes.h"\r
+\r
+#ifdef LOGSTDERR\r
+static inline void gslog(int loglevel, const char * format, ...) {\r
+    va_list args;\r
+    va_start(args, format);\r
+    if (loglevel >= LOG_WARNING) {\r
+        vfprintf(stdout, format, args);\r
+        // Not generally syslog messages do not contain a \n so we need to add one for stdout/stderr\r
+        fprintf(stdout, "\n");\r
+        fflush(stdout);\r
+    } else {\r
+        //STDERR is not-buffered by default.\r
+        vfprintf(stderr, format, args);\r
+        fprintf(stderr, "\n");\r
+    }\r
+    va_end(args);\r
+}\r
+\r
+static inline void gsopenlog(gs_sp_t p) {\r
+    return;\r
+}\r
+\r
+#else\r
+\r
+#define gslog syslog\r
+\r
+#ifndef LOG_EMERG\r
+#define LOG_EMERG 7\r
+#endif\r
+\r
+// some state used for reporting\r
+\r
+extern gs_uint64_t intupledrop;\r
+extern gs_uint64_t outtupledrop;\r
+extern gs_uint64_t intuple;\r
+extern gs_uint64_t outtuple;\r
+extern gs_uint64_t inbytes;\r
+extern gs_uint64_t outbytes;\r
+extern gs_uint64_t cycles;\r
+\r
+\r
+static inline void gsopenlog(gs_sp_t p) {\r
+       gs_int8_t c[HOST_NAME_MAX+1];\r
+       gs_int8_t t[HOST_NAME_MAX+1+1000];\r
+       gs_sp_t t2;\r
+       if (gethostname(&c[0],HOST_NAME_MAX+1)!=0) {\r
+               fprintf(stderr,"GSCPV1::ERROR:could not get hostname\n");\r
+               exit(1);\r
+       }\r
+       c[HOST_NAME_MAX]=0;\r
+       sprintf(t,"GSCPv2:%s:%s:",c,p);\r
+       t2=strdup(t);\r
+       openlog(t2,LOG_NOWAIT|LOG_PID|LOG_CONS,LOG_LOCAL5);\r
+       gslog(LOG_INFO,"Started Logging");\r
+       intupledrop=0;\r
+       outtupledrop=0;\r
+       intuple=0;\r
+       outtuple=0;\r
+       inbytes=0;\r
+       outbytes=0;\r
+       cycles=0;\r
+}\r
+#endif\r
+\r
+static inline void gsstats() {\r
+       gs_uint32_t t;\r
+       //t=time(0);\r
+       //gslog(LOG_NOTICE,"STATS|%u|%llu|%llu|%llu|%llu|%llu|%llu|%llu",t,intuple,inbytes,intupledrop,outtuple,outbytes,outtupledrop,cycles);\r
+}\r
+\r
+#endif\r