Commit 0d1ea0a ymolodkov
committed
1 parent 2d9c48b commit 0d1ea0a Copy full SHA for 0d1ea0a
File tree 12 files changed +148
-4
lines changed
java/com/odysseusinc/arachne/datanode/controller
12 files changed +148
-4
lines changed Original file line number Diff line number Diff line change 9
9
"users" : " Users" ,
10
10
"databases" : " Databases" ,
11
11
"envs" : " Environments" ,
12
- "system_settings" : " System Settings"
12
+ "system_settings" : " System Settings" ,
13
+ "application_log" : " Application log"
13
14
},
14
15
"pages" : {
15
16
"login" : {
28
29
"databases" : " Databases" ,
29
30
"users" : " Users" ,
30
31
"envs" : " Environments" ,
31
- "system_settings" : " System Settings"
32
+ "system_settings" : " System Settings" ,
33
+ "application_log" : " Application log"
32
34
},
33
35
"users" : {
34
36
"header" : " Users" ,
Original file line number Diff line number Diff line change 16
16
*/
17
17
18
18
import { api } from "." ;
19
- import { UserDTOSearchInterface } from "../libs/types" ;
19
+ import { UserDTOInterface , UserDTOSearchInterface } from "../libs/types" ;
20
20
21
21
export const getUsers = ( ) : Promise < UserDTOSearchInterface [ ] > =>
22
22
api . get ( "/admin/admins" ) ;
@@ -34,3 +34,4 @@ export const systemSettings = (): Promise<any> => api.get("/admin/system-setting
34
34
35
35
export const updateSystemSettings = ( value ) : Promise < any > => api . post ( "/admin/system-settings" , value ) ;
36
36
37
+ export const getApplicationLog = ( ) : Promise < string > => api . get ( `/application/logs/` ) ;
Original file line number Diff line number Diff line change @@ -365,4 +365,8 @@ export const tabsAdmin = (t: any): TabsInterface[] => [
365
365
value : "system-settings" ,
366
366
title : t ( "pages.administration.tabs.system_settings" ) ,
367
367
} ,
368
+ {
369
+ value : "application-log" ,
370
+ title : t ( "pages.administration.tabs.application_log" ) ,
371
+ }
368
372
] ;
Original file line number Diff line number Diff line change @@ -23,4 +23,5 @@ export * from "./useList";
23
23
export * from "./useModal" ;
24
24
export * from "./useInterval" ;
25
25
export * from "./useSystemSettings" ;
26
- export * from "./useSubmissionLog" ;
26
+ export * from "./useSubmissionLog" ;
27
+ export * from "./useApplicaionLog" ;
Original file line number Diff line number Diff line change
1
+ export * from "./useApplicationLog" ;
Original file line number Diff line number Diff line change
1
+ import { useState , useEffect } from 'react' ;
2
+ import { getApplicationLog } from "../../../api/admin" ;
3
+ import { useInterval } from '../useInterval' ;
4
+
5
+ export const useApplicationLog = ( ) => {
6
+ const [ logs , setLogs ] = useState < string > ( '' ) ;
7
+ const [ loading , setLoading ] = useState < boolean > ( true ) ;
8
+ const [ error , setError ] = useState < string | null > ( null ) ;
9
+
10
+ const fetchLogs = async ( ) => {
11
+ try {
12
+ const response = await getApplicationLog ( ) ;
13
+ setLogs ( response ) ;
14
+ setError ( null ) ;
15
+ } catch ( err ) {
16
+ setError ( 'Error fetching logs' ) ;
17
+ } finally {
18
+ setLoading ( false ) ;
19
+ }
20
+ } ;
21
+
22
+ useInterval ( ( ) => {
23
+ fetchLogs ( ) ;
24
+ // }, 10000);
25
+ } , 10000 ) ;
26
+
27
+ useEffect ( ( ) => {
28
+ fetchLogs ( ) ;
29
+ } , [ ] ) ;
30
+
31
+ return { logs, loading, error } ;
32
+ } ;
33
+
Original file line number Diff line number Diff line change @@ -30,6 +30,10 @@ export const tabsAdmin: TabsInterface[] = [
30
30
value : "environments" ,
31
31
title : "Enviroments" ,
32
32
} ,
33
+ {
34
+ value : 'application-log' ,
35
+ title : 'Application log' ,
36
+ } ,
33
37
{
34
38
value : "system-settings" ,
35
39
title : "System settings" ,
Original file line number Diff line number Diff line change
1
+ import React , { useEffect } from "react" ;
2
+ import { Grid , Paper } from "@mui/material" ;
3
+ import { useTranslation } from "react-i18next" ;
4
+ import { CodeEditor } from "../../../libs/components" ;
5
+ import { useDispatch } from "react-redux" ;
6
+ import { setBreadcrumbs } from "../../../store/modules" ;
7
+ import { useApplicationLog } from "../../../libs/hooks" ;
8
+
9
+ export const ApplicationLog : React . FC = ( ) => {
10
+ const { logs, loading, error} = useApplicationLog ( ) ;
11
+ const dispatch = useDispatch ( ) ;
12
+ const { t} = useTranslation ( ) ;
13
+
14
+ useEffect ( ( ) => {
15
+ dispatch (
16
+ setBreadcrumbs ( [
17
+ {
18
+ name : t ( "breadcrumbs.admin" ) ,
19
+ path : "/administration" ,
20
+ } ,
21
+ {
22
+ name : t ( "breadcrumbs.application_log" ) ,
23
+ path : "/application-log" ,
24
+ } ,
25
+ ] )
26
+ ) ;
27
+ } , [ dispatch , t ] ) ;
28
+
29
+ return (
30
+ < Paper elevation = { 0 } sx = { { p : 2 } } >
31
+ { loading ? (
32
+ < div > Loading...</ div >
33
+ ) : error ? (
34
+ < div > { error } </ div >
35
+ ) : logs ? (
36
+ < CodeEditor
37
+ data = { logs || "" }
38
+ height = { "73vh" }
39
+ containerStyles = { { padding : 0 } }
40
+ enableDownload = { true }
41
+ enableCopy
42
+ readOnly
43
+ consoleMode
44
+ />
45
+ ) : (
46
+ < Grid item xs = { 12 } >
47
+ { /*<NoDataContainer>No available logs</NoDataContainer>*/ }
48
+ </ Grid >
49
+ ) }
50
+ </ Paper >
51
+ ) ;
52
+ } ;
Original file line number Diff line number Diff line change
1
+ /*
2
+ *
3
+ * Copyright 2023 Odysseus Data Services, Inc.
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ *
16
+ */
17
+
18
+ export * from "./ApplicationLog" ;
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ import { Databases } from "./Databases";
29
29
import { Users } from "./Users" ;
30
30
import { SystemSettings } from "./SystemSettings" ;
31
31
import { EnviromentsList } from "./Enviroments" ;
32
+ import { ApplicationLog } from "./ApplicationLog" ;
32
33
import { tabsAdmin } from "../../config" ;
33
34
34
35
export const IndexAdmin : React . FC = ( ) => {
@@ -66,6 +67,7 @@ export const IndexAdmin: React.FC = () => {
66
67
< Route path = "users/*" element = { < Users /> } />
67
68
< Route path = "environments/*" element = { < EnviromentsList /> } />
68
69
< Route path = "system-settings/*" element = { < SystemSettings /> } />
70
+ < Route path = "application-log/*" element = { < ApplicationLog /> } />
69
71
</ Routes >
70
72
</ Grid >
71
73
) ;
Original file line number Diff line number Diff line change
1
+ package com .odysseusinc .arachne .datanode .controller ;
2
+
3
+ import org .springframework .beans .factory .annotation .Value ;
4
+ import org .springframework .http .ResponseEntity ;
5
+ import org .springframework .stereotype .Controller ;
6
+ import org .springframework .web .bind .annotation .RequestMapping ;
7
+ import org .springframework .web .bind .annotation .RequestMethod ;
8
+
9
+ import java .io .IOException ;
10
+ import java .nio .file .Files ;
11
+ import java .nio .file .Paths ;
12
+
13
+ @ Controller
14
+ public class LogController {
15
+
16
+ @ Value ("${logging.file.name}" )
17
+ private String logFilePath ;
18
+
19
+ @ RequestMapping (method = RequestMethod .GET , value = "/api/v1/application/logs/" )
20
+ public ResponseEntity <String > getLogs () throws IOException {
21
+ String logs = new String (Files .readAllBytes (Paths .get (logFilePath )));
22
+ return ResponseEntity .ok (logs );
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -145,6 +145,8 @@ security:
145
145
validityInSeconds : ${datanode.jwt.expiration}
146
146
147
147
logging :
148
+ file :
149
+ name : logs/arachne.log
148
150
level :
149
151
root : INFO
150
152
org.springframework.web.servlet.PageNotFound : ERROR
You can’t perform that action at this time.
0 commit comments