Skip to content

Commit

Permalink
Add the rest of the logging information to database.
Browse files Browse the repository at this point in the history
Add a few more fields to the DB logging table, so that it contains the
same useful information that's in the file logs.
  • Loading branch information
sphery committed Dec 15, 2011
1 parent e94c6d9 commit cd06560
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 5 deletions.
2 changes: 1 addition & 1 deletion mythtv/bindings/perl/MythTV.pm
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ package MythTV;
# schema version supported in the main code. We need to check that the schema
# version in the database is as expected by the bindings, which are expected
# to be kept in sync with the main code.
our $SCHEMA_VERSION = "1290";
our $SCHEMA_VERSION = "1291";

# NUMPROGRAMLINES is defined in mythtv/libs/libmythtv/programinfo.h and is
# the number of items in a ProgramInfo QStringList group used by
Expand Down
2 changes: 1 addition & 1 deletion mythtv/bindings/python/MythTV/static.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""

OWN_VERSION = (0,25,-1,3)
SCHEMA_VERSION = 1290
SCHEMA_VERSION = 1291
NVSCHEMA_VERSION = 1007
MUSICSCHEMA_VERSION = 1018
PROTO_VERSION = '70'
Expand Down
11 changes: 9 additions & 2 deletions mythtv/libs/libmythbase/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,8 +376,10 @@ DatabaseLogger::DatabaseLogger(char *table) : LoggerBase(table, 0),
{
m_query = QString(
"INSERT INTO %1 "
" (host, application, pid, thread, msgtime, level, message) "
"VALUES (:HOST, :APP, :PID, :THREAD, :MSGTIME, :LEVEL, :MESSAGE)")
" (host, application, pid, tid, thread, filename, "
" line, function, msgtime, level, message) "
"VALUES (:HOST, :APP, :PID, :TID, :THREAD, :FILENAME, "
" :LINE, :FUNCTION, :MSGTIME, :LEVEL, :MESSAGE)")
.arg(m_handle.string);

LOG(VB_GENERAL, LOG_INFO,
Expand Down Expand Up @@ -450,11 +452,16 @@ bool DatabaseLogger::logqmsg(MSqlQuery &query, LoggingItem *item)
{
char timestamp[TIMESTAMP_MAX];
char *threadName = getThreadName(item);
pid_t tid = getThreadTid(item);

strftime( timestamp, TIMESTAMP_MAX-8, "%Y-%m-%d %H:%M:%S",
(const struct tm *)&item->tm );

query.bindValue(":TID", tid);
query.bindValue(":THREAD", threadName);
query.bindValue(":FILENAME", item->file);
query.bindValue(":LINE", item->line);
query.bindValue(":FUNCTION", item->function);
query.bindValue(":MSGTIME", timestamp);
query.bindValue(":LEVEL", item->level);
query.bindValue(":MESSAGE", item->message);
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
* MythTV Python Bindings
* mythtv/bindings/python/MythTV/static.py
*/
#define MYTH_DATABASE_VERSION "1290"
#define MYTH_DATABASE_VERSION "1291"


MBASE_PUBLIC const char *GetMythSourceVersion();
Expand Down
21 changes: 21 additions & 0 deletions mythtv/libs/libmythtv/dbcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6048,6 +6048,27 @@ NULL
return false;
}

if (dbver == "1290")
{
const char *updates[] = {
"ALTER TABLE logging "
" ALTER COLUMN host SET DEFAULT '', "
" ALTER COLUMN application SET DEFAULT '', "
" ALTER COLUMN pid SET DEFAULT '0', "
" ALTER COLUMN thread SET DEFAULT '', "
" ALTER COLUMN level SET DEFAULT '0';",
"ALTER TABLE logging "
" ADD COLUMN tid INT(11) NOT NULL DEFAULT '0' AFTER pid, "
" ADD COLUMN filename VARCHAR(255) NOT NULL DEFAULT '' AFTER thread, "
" ADD COLUMN line INT(11) NOT NULL DEFAULT '0' AFTER filename, "
" ADD COLUMN function VARCHAR(255) NOT NULL DEFAULT '' AFTER line;",
NULL
};

if (!performActualUpdate(updates, "1291", dbver))
return false;
}

return true;
}

Expand Down

0 comments on commit cd06560

Please sign in to comment.