Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mariadb
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
mariadb
Commits
e9c0a17c
Commit
e9c0a17c
authored
Dec 22, 2004
by
tomas@poseidon.ndb.mysql.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added handling of repeated messages
parent
99622f3f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
6 deletions
+65
-6
ndb/include/logger/LogHandler.hpp
ndb/include/logger/LogHandler.hpp
+10
-0
ndb/src/common/logger/LogHandler.cpp
ndb/src/common/logger/LogHandler.cpp
+54
-5
ndb/src/common/transporter/Transporter.hpp
ndb/src/common/transporter/Transporter.hpp
+1
-1
No files found.
ndb/include/logger/LogHandler.hpp
View file @
e9c0a17c
...
@@ -192,6 +192,16 @@ private:
...
@@ -192,6 +192,16 @@ private:
const
char
*
m_pDateTimeFormat
;
const
char
*
m_pDateTimeFormat
;
int
m_errorCode
;
int
m_errorCode
;
// for handling repeated messages
unsigned
m_count_repeated_messages
;
unsigned
m_max_repeat_frequency
;
time_t
m_last_log_time
;
char
m_last_category_buf
[
16
];
char
m_last_message_buf
[
256
];
char
*
m_last_category
;
Logger
::
LoggerLevel
m_last_level
;
char
*
m_last_message
;
};
};
#endif
#endif
ndb/src/common/logger/LogHandler.cpp
View file @
e9c0a17c
...
@@ -23,22 +23,71 @@
...
@@ -23,22 +23,71 @@
//
//
LogHandler
::
LogHandler
()
:
LogHandler
::
LogHandler
()
:
m_pDateTimeFormat
(
"%d-%.2d-%.2d %.2d:%.2d:%.2d"
),
m_pDateTimeFormat
(
"%d-%.2d-%.2d %.2d:%.2d:%.2d"
),
m_errorCode
(
0
)
m_errorCode
(
0
),
{
m_last_category
(
m_last_category_buf
),
m_last_message
(
m_last_message_buf
)
{
m_max_repeat_frequency
=
3
;
// repeat messages maximum every 3 seconds
m_last_category_buf
[
0
]
=
0
;
m_last_message_buf
[
0
]
=
0
;
}
}
LogHandler
::~
LogHandler
()
LogHandler
::~
LogHandler
()
{
{
if
(
m_last_message
!=
m_last_message_buf
)
free
(
m_last_message
);
if
(
m_last_category
!=
m_last_category_buf
)
free
(
m_last_category
);
}
}
void
void
LogHandler
::
append
(
const
char
*
pCategory
,
Logger
::
LoggerLevel
level
,
LogHandler
::
append
(
const
char
*
pCategory
,
Logger
::
LoggerLevel
level
,
const
char
*
pMsg
)
const
char
*
pMsg
)
{
{
time_t
now
;
now
=
::
time
((
time_t
*
)
NULL
);
if
(
level
!=
m_last_level
||
strcmp
(
pCategory
,
m_last_category
)
||
strcmp
(
pMsg
,
m_last_message
))
{
if
(
m_last_message
!=
m_last_message_buf
)
free
(
m_last_message
);
if
(
m_last_category
!=
m_last_category_buf
)
free
(
m_last_category
);
m_count_repeated_messages
=
0
;
m_last_level
=
level
;
BaseString
::
snprintf
(
m_last_category_buf
,
sizeof
(
m_last_category_buf
),
"%s"
,
pCategory
);
BaseString
::
snprintf
(
m_last_message_buf
,
sizeof
(
m_last_message_buf
),
"%s"
,
pMsg
);
// ToDo: handle too long messages correctly
// right now all that will happen is that too long messages
// will be repeated unneccesarily
}
else
// repeated message
{
if
(
now
<
m_last_log_time
+
m_max_repeat_frequency
)
{
m_count_repeated_messages
++
;
return
;
}
}
writeHeader
(
pCategory
,
level
);
writeHeader
(
pCategory
,
level
);
writeMessage
(
pMsg
);
if
(
m_count_repeated_messages
==
0
)
writeMessage
(
pMsg
);
else
{
BaseString
str
(
pMsg
);
str
.
appfmt
(
" - repeated %d times"
,
m_count_repeated_messages
);
writeMessage
(
str
.
c_str
());
m_count_repeated_messages
=
0
;
}
writeFooter
();
writeFooter
();
}
m_last_log_time
=
now
;
}
const
char
*
const
char
*
LogHandler
::
getDefaultHeader
(
char
*
pStr
,
const
char
*
pCategory
,
LogHandler
::
getDefaultHeader
(
char
*
pStr
,
const
char
*
pCategory
,
...
...
ndb/src/common/transporter/Transporter.hpp
View file @
e9c0a17c
...
@@ -151,7 +151,7 @@ Transporter::getRemoteNodeId() const {
...
@@ -151,7 +151,7 @@ Transporter::getRemoteNodeId() const {
inline
inline
NodeId
NodeId
Transporter
::
getLocalNodeId
()
const
{
Transporter
::
getLocalNodeId
()
const
{
return
remote
NodeId
;
return
local
NodeId
;
}
}
inline
inline
...
...
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