yumapro  23.10T-7
YumaPro SDK
Loading...
Searching...
No Matches
log_util.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012 - 2021, YumaWorks, Inc., All Rights Reserved.
3 *
4 * Unless required by applicable law or agreed to in writing,
5 * software distributed under the License is distributed on an
6 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
7 * KIND, either express or implied. See the License for the
8 * specific language governing permissions and limitations
9 * under the License.
10 */
11#ifndef _H_log_util
12#define _H_log_util
13/* FILE: log_util.h
14*********************************************************************
15* *
16* P U R P O S E *
17* *
18*********************************************************************/
19
25/*********************************************************************
26* *
27* C H A N G E H I S T O R Y *
28* *
29*********************************************************************
30
31date init comment
32----------------------------------------------------------------------
3308-jan-06 abb begun
3402-jun-2012 mts adapted from log.h
35*/
36
37#include <stdio.h>
38#include <xmlstring.h>
39
40#include "procdefs.h"
41#include "status.h"
42#include "log.h"
43
44#ifdef __cplusplus
45extern "C" {
46#endif
47
48/********************************************************************
49* *
50* C O N S T A N T S *
51* *
52*********************************************************************/
53
54/*
55 * Update of the internal syslog buffer is based on:
56 *
57 * vsnprintf()
58 *
59 * This primitive expects the content area to be followed by an additional
60 * byte in order to append a NULL terminator to a max size content string.
61 * We in turn add yet another byte to store a well known marker byte in an
62 * attempt to detect errors and aid debugging. (Not rigorous, but better
63 * than nothing.)
64 *
65 * The below defs do this:
66 *
67 */
68
69//#define SYSLOG_BUF_CONTENT_SIZE 64 /* For overflow testing */
70#define SYSLOG_BUF_CONTENT_SIZE 1024 /* Max syslog buffer content size */
71#define SYSLOG_BUF_NULL_BYTE_SIZE 1 /* Add a byte for a NULL terminator */
72#define SYSLOG_BUF_MARKER_BYTE_SIZE 1 /* Add a byte for a well known marker */
73
74#define SYSLOG_BUF_TOTAL_SIZE (SYSLOG_BUF_CONTENT_SIZE + \
75 SYSLOG_BUF_NULL_BYTE_SIZE + \
76 SYSLOG_BUF_MARKER_BYTE_SIZE)
77
78#define SYSLOG_BUF_NULL_BYTE_INDEX (SYSLOG_BUF_CONTENT_SIZE + \
79 SYSLOG_BUF_NULL_BYTE_SIZE - 1)
80
81#define SYSLOG_BUF_MARKER_BYTE_INDEX (SYSLOG_BUF_CONTENT_SIZE + \
82 SYSLOG_BUF_NULL_BYTE_SIZE + \
83 SYSLOG_BUF_MARKER_BYTE_SIZE - 1)
84
85#define LOG_PRIO_NONE (-1)
86
87/********************************************************************
88* *
89* T Y P E S *
90* *
91*********************************************************************/
92
93
101typedef struct syslog_msg_desc_t_ {
102 uint idid;
103 char *start;
104 char *end;
105 char *ptr;
106 uint32 len;
107 int32 remaining;
108 boolean initialized;
109 boolean was_append;
110 boolean first_time;
115 char buf[SYSLOG_BUF_TOTAL_SIZE];
117
118
119/********************************************************************
120* *
121* F U N C T I O N S *
122* *
123*********************************************************************/
124
125
131extern void
133
134
140extern void
142
143
156extern void
158 log_debug_app_t app,
159 log_debug_t level,
160 log_debug_t sub_level,
161 const char *fstr,
162 va_list args);
163
164
177extern void
179 log_debug_app_t app,
180 log_debug_t level,
181 log_debug_t sub_level,
182 const char *fstr,
183 va_list args);
184
185
186
190#ifdef __cplusplus
191} /* end extern 'C' */
192#endif
193
194#endif /* _H_log_util */
log_debug_app_t
syslog wants to know what app is logging ...
Definition: log.h:362
log_debug_t
The debug level enumerations used in util/log.c.
Definition: log.h:343
void log_util_init_buf(syslog_msg_desc_t *dp)
Initialize the contents of an internal log buffer descriptor.
Definition: log_util.c:93
void log_util_flush(syslog_msg_desc_t *desc)
Flush contents of internal buffer to external logging system.
Definition: log_util.c:530
void log_util_logbuf_common(syslog_msg_desc_t *desc, log_debug_app_t app, log_debug_t level, log_debug_t sub_level, const char *fstr, va_list args)
Send formatted string output to an internal log buffer.
Definition: log_util.c:554
void log_util_logbuf_append(syslog_msg_desc_t *desc, log_debug_app_t app, log_debug_t level, log_debug_t sub_level, const char *fstr, va_list args)
Append formatted string output to an internal log buffer.
Definition: log_util.c:593
NCX System Logging Manager.
Global error messages for status code enumerations.
Syslog/Vendor Message Buffer descriptor.
Definition: log_util.h:101
uint idid
internal idid field
Definition: log_util.h:102
uint32 len
message len
Definition: log_util.h:106
log_debug_t level
debug level to use
Definition: log_util.h:113
boolean write_pending
internal write pending
Definition: log_util.h:111
int32 remaining
remaining to write
Definition: log_util.h:107
log_debug_t sub_level
sub-level to use
Definition: log_util.h:114
char * end
end of message
Definition: log_util.h:104
char * ptr
internal message pointer
Definition: log_util.h:105
boolean first_time
first callflag
Definition: log_util.h:110
log_debug_app_t app
app to use in message
Definition: log_util.h:112
char * start
start of message
Definition: log_util.h:103
boolean initialized
initialization done
Definition: log_util.h:108
boolean was_append
was appended flag
Definition: log_util.h:109