Added StoredProcedure LogMessageAdd for Logging

This commit is contained in:
Patrick Keist 2019-02-10 12:11:43 +01:00
parent 54a0eae651
commit 0517f7b803
2 changed files with 22 additions and 5 deletions

View File

@ -210,10 +210,10 @@ FOREIGN KEY (credentials_credentials_id) REFERENCES Credentials (credentials_id)
CREATE TABLE IF NOT EXISTS v_logentries (
v_logentries_id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
pod VARCHAR(1000),
location VARCHAR(1000)
location VARCHAR(1000),
hostname VARCHAR(45),
severity INT,
timestamp TIMESTAMP;
timestamp TIMESTAMP,
message VARCHAR(1000)
);
@ -238,6 +238,23 @@ BEGIN
END //
DELIMITER ;
# Stored Procedure für schreiben der Logs Anhand der Inputparameter
DELIMITER //
CREATE PROCEDURE LogMessageAdd
(
IN device_id INT, log_level ENUM('Low','Middle','High'), logMessageInsert VARCHAR(255)
)
BEGIN
INSERT INTO log ( device_fk, `timestamp`, logMessage, `level`, is_acknowledged)
VALUE
(device_id, timestamp(now()), logMessageInsert, log_level, 0);
END //
DELIMITER ;
# View für das anzeigen nicht belegter Interfaces
CREATE VIEW
view_freiesInterface (LocationName, Hostname, Portnummer, Medium, Geschwindigkeit)

View File

@ -127,9 +127,9 @@ VALUES
INSERT INTO Log (logMessage, timestamp, level, is_acknowledged, device_fk)
VALUES
('Loged In',now(),'Low',0,1),
('Loged Out',now(),'Low'0,,1),
('Loged In',now(),'Low'0,,2),
('Virus detected',now(),'High'0,,3)
('Loged Out',now(),'Low',0,1),
('Loged In',now(),'Low',0,2),
('Virus detected',now(),'High',0,3)
;
INSERT INTO Abrechnung (kundenkonto_fk, location_fk, device_fk, interface_fk)