From 0517f7b803613114ca67b09f8ff746116df546ab Mon Sep 17 00:00:00 2001
From: Patrick Keist
Date: Sun, 10 Feb 2019 12:11:43 +0100
Subject: [PATCH] Added StoredProcedure LogMessageAdd for Logging
---
MySQL/Skript_DDL.sql | 21 +++++++++++++++++++--
MySQL/Skript_DML.sql | 6 +++---
2 files changed, 22 insertions(+), 5 deletions(-)
diff --git a/MySQL/Skript_DDL.sql b/MySQL/Skript_DDL.sql
index ece103e..137f754 100644
--- a/MySQL/Skript_DDL.sql
+++ b/MySQL/Skript_DDL.sql
@@ -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)
diff --git a/MySQL/Skript_DML.sql b/MySQL/Skript_DML.sql
index f271bd4..8381a35 100644
--- a/MySQL/Skript_DML.sql
+++ b/MySQL/Skript_DML.sql
@@ -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)