diff --git a/src/App.tsx b/src/App.tsx index 3758237..8f928ae 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -11,14 +11,15 @@ import TableRow from '@mui/material/TableRow'; import Paper from '@mui/material/Paper'; import { TableHead } from "@mui/material"; -type getMessageReturn = [string[],string[],string[],string[],number[]] +type getMessageReturn = [string[],string[],string[],string[],number[],string[]] function App() { const [time, setTime] = useState([]); - const [source, setSource] = useState([]); + const [host, setHost] = useState([]); const [debug, setDebug] = useState([]); const [logs, setLogs] = useState([]); const [log_lvl, setLog_lvl] = useState([]); + const [app_name,setApp_name] = useState([]); useEffect(() => { async function fetchData( @@ -50,12 +51,13 @@ function App() { // Parsing the response as JSON const logdata = await response.json(); - const [timestamp,source,debug,message,log_level] = getMessage(logdata) || [["No logs found"],["No logs found"],["No logs found"],["No logs found"],[1]]; + const [timestamp,host,debug,message,log_level,app_name] = getMessage(logdata) || [["No logs found"],["No logs found"],["No logs found"],["No logs found"],[7],["No logs found"]]; setTime(timestamp); - setSource(source); + setHost(host); setDebug(debug); setLogs(message); setLog_lvl(log_level); + setApp_name(app_name); } catch (error) { console.error("Error fetching data:", error); throw error; @@ -133,17 +135,19 @@ function App() { Timestamp Debugging Level - Source + Host + App Name Log Messages {logs.map((log,index) => ( - {time[index]} - {debug[index]} - {source[index]} - {log} +
{time[index]}
+
{debug[index]}
+
{host[index]}
+
{app_name[index]}
+
{log}
{/* sx={{ '&:last-child td, &:last-child th': { border: 0 } }} */}
))} @@ -162,9 +166,10 @@ function getMessage(logging: JSON): undefined | getMessageReturn { const id = data.results[key].search_types; const message: string[] = []; const timestamp: string[] =[]; - const source: string[] =[]; + const host:string[] = []; const debug: string[] =[]; const log_level: number[] =[]; + const app_name: string[] = []; for (const keys in id) { if ("messages" in id[keys]) { const logs = id[keys].messages; @@ -174,9 +179,8 @@ function getMessage(logging: JSON): undefined | getMessageReturn { timestamp.push( `${formattedTimestamp}` ); - source.push( - `${logs[msg]["message"]["source"]}` - ) + host.push(logs[msg]["message"]["source"]) + app_name.push(logs[msg]["message"]["application_name"]); const text = logs[msg]["message"]["message"]; const [debug_level, log_message,level] = logLevel(text); debug.push(debug_level); @@ -184,7 +188,7 @@ function getMessage(logging: JSON): undefined | getMessageReturn { log_level.push(level); } - return [timestamp,source,debug,message,log_level]; + return [timestamp,host,debug,message,log_level,app_name]; } } }