Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
23b0387a
Commit
23b0387a
authored
May 26, 2000
by
Tatsuo Ishii
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix too long syslog message problem
parent
8bba4b4e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
81 additions
and
1 deletion
+81
-1
src/backend/utils/misc/trace.c
src/backend/utils/misc/trace.c
+81
-1
No files found.
src/backend/utils/misc/trace.c
View file @
23b0387a
...
@@ -24,6 +24,12 @@
...
@@ -24,6 +24,12 @@
#include "miscadmin.h"
#include "miscadmin.h"
#include "utils/trace.h"
#include "utils/trace.h"
#include <ctype.h>
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
/*
/*
* We could support trace messages of indefinite length, as elog() does,
* We could support trace messages of indefinite length, as elog() does,
* but it's probably not worth the trouble. Instead limit trace message
* but it's probably not worth the trouble. Instead limit trace message
...
@@ -204,16 +210,90 @@ eprintf(const char *fmt,...)
...
@@ -204,16 +210,90 @@ eprintf(const char *fmt,...)
void
void
write_syslog
(
int
level
,
char
*
line
)
write_syslog
(
int
level
,
char
*
line
)
{
{
#ifndef PG_SYSLOG_LIMIT
#define PG_SYSLOG_LIMIT 128
#endif
/* PG_SYSLOG_LIMIT */
static
int
openlog_done
=
0
;
static
int
openlog_done
=
0
;
static
char
buf
[
PG_SYSLOG_LIMIT
+
1
];
static
int
logid
=
0
;
if
(
UseSyslog
>=
1
)
if
(
UseSyslog
>=
1
)
{
{
int
len
=
strlen
(
line
);
int
buflen
;
int
seq
=
0
;
int
l
;
int
i
;
if
(
!
openlog_done
)
if
(
!
openlog_done
)
{
{
openlog_done
=
1
;
openlog_done
=
1
;
openlog
(
PG_LOG_IDENT
,
LOG_PID
|
LOG_NDELAY
,
PG_LOG_FACILITY
);
openlog
(
PG_LOG_IDENT
,
LOG_PID
|
LOG_NDELAY
,
PG_LOG_FACILITY
);
}
}
syslog
(
level
,
"%s"
,
line
);
/* divide into multiple syslog() calls if message is
* too long
*/
if
(
len
>
PG_SYSLOG_LIMIT
)
{
logid
++
;
while
(
len
>
0
)
{
strncpy
(
buf
,
line
,
PG_SYSLOG_LIMIT
);
buf
[
PG_SYSLOG_LIMIT
]
=
'\0'
;
l
=
strlen
(
buf
);
#ifdef MULTIBYTE
/* trim to multibyte letter boundary */
buflen
=
pg_mbcliplen
(
buf
,
l
,
l
);
buf
[
buflen
]
=
'\0'
;
l
=
strlen
(
buf
);
#endif
/* already word boundary? */
if
(
isspace
(
line
[
l
])
||
line
[
l
]
==
'\0'
)
{
buflen
=
l
;
}
else
{
/* try to divide in word boundary */
i
=
l
-
1
;
while
(
i
>
0
&&
!
isspace
(
buf
[
i
]))
{
i
--
;
}
if
(
i
<=
0
)
/* couldn't divide word boundary */
{
buflen
=
l
;
}
else
{
buflen
=
i
;
buf
[
i
]
=
'\0'
;
}
}
seq
++
;
/*
* Here we actually call syslog().
* For segmented messages, we add logid
* (incremented at each write_syslog call),
* and seq (incremented at each syslog call
* within a write_syslog call).
* This will prevent syslog to surpress
* "same" messages...
*/
syslog
(
level
,
"[%d-%d] %s"
,
logid
,
seq
,
buf
);
line
+=
buflen
;
len
-=
buflen
;
}
}
else
{
syslog
(
level
,
"%s"
,
line
);
}
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment