Skip to main content
deleted 35 characters in body
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. I'd be thankful for any suggestions. This library is going to be used from all of my other programs and it is therefore important to keep the code clean and secure.

Here is also the definition of my LOG_ENTRYLOG_ENTRY struct.:

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. I'd be thankful for any suggestions. This library is going to be used from all of my other programs and it is therefore important to keep the code clean and secure.

Here is also the definition of my LOG_ENTRY struct.

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. This library is going to be used from all of my other programs and it is therefore important to keep the code clean and secure.

Here is also the definition of my LOG_ENTRY struct:

deleted 15 characters in body; edited title
Source Link
200_success
  • 145.7k
  • 22
  • 191
  • 481

Messy code Small library for smalllogging to MySQL Library

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. I'd be thankful for any suggestions. This library is going to be used from all of my other programs and it is therefortherefore important to keep the code clean and secure.

(EDIT: Here is the table structure of logg

)

Messy code for small MySQL Library

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. I'd be thankful for any suggestions. This library is going to be used from all of my other programs and it is therefor important to keep the code clean and secure.

(EDIT: Here is the table structure of logg

)

Small library for logging to MySQL

I've thrown together a utility for my programs to log to a database, but the code looks like a mess and I don't know how to clean it up. I'd be thankful for any suggestions. This library is going to be used from all of my other programs and it is therefore important to keep the code clean and secure.

Here is the table structure of logg

Added struct definition, and MySQL table structure.
Source Link
Linus
  • 937
  • 5
  • 18

(EDIT: Here is the table structure of logg

CREATE TABLE IF NOT EXISTS `logg` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `severity` tinyint(4) NOT NULL,
  `event` varchar(128) NOT NULL,
  `source` varchar(32) NOT NULL,
  `time` time NOT NULL,
  `date` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;

I limit the length to avoid any potential security risk, and save storage in my database. I don't really need any longer log messages.

Here is also the definition of my LOG_ENTRY struct.

typedef struct {
    int severity;
    char *event ;
    char *source;
    struct tm *tm_info;
} LOG_ENTRY;

)

(EDIT: Here is the table structure of logg

CREATE TABLE IF NOT EXISTS `logg` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `severity` tinyint(4) NOT NULL,
  `event` varchar(128) NOT NULL,
  `source` varchar(32) NOT NULL,
  `time` time NOT NULL,
  `date` date NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=18 ;

I limit the length to avoid any potential security risk, and save storage in my database. I don't really need any longer log messages.

Here is also the definition of my LOG_ENTRY struct.

typedef struct {
    int severity;
    char *event ;
    char *source;
    struct tm *tm_info;
} LOG_ENTRY;

)

edited tags
Link
200_success
  • 145.7k
  • 22
  • 191
  • 481
Loading
Source Link
Linus
  • 937
  • 5
  • 18
Loading