TreeMig Code
Loading...
Searching...
No Matches
LoggerModule.f90
Go to the documentation of this file.
1!=====================================================================
8!===============================================================
10 use filehandlingmodule, only: file
11 TYPE(File) :: LogFile
12 LOGICAL :: initialized;
13 INTEGER :: err
14 ! LogMessage can be used to write variables write (logMessage, *) var
15 ! LogInfo(LogMessage)
16 character(len=1024) :: logmessage
17 private :: logfile, initialized, err, file
18contains
19!===============================================================
20!=====================================================================
38!===============================================================
39 SUBROUTINE initlogger(Log_file)
41 TYPE(file), INTENT(in) :: Log_file
42 call openfilew(log_file, err)
43 logfile = log_file
44 initialized = .true.
45 end SUBROUTINE initlogger
46!=====================================================================
63!===============================================================
64 SUBROUTINE stoplogger()
66 initialized = .false.
67 call closefile(logfile)
68 end SUBROUTINE stoplogger
69!=====================================================================
81!===============================================================
82 SUBROUTINE logerror(msg)
83 character(len=*), INTENT(in) :: msg
84 call logall("Error", msg)
85 end SUBROUTINE logerror
86!=====================================================================
98!===============================================================
99 SUBROUTINE logwarning(msg)
100 character(len=*), INTENT(in) :: msg
101 call logall("Warning", msg)
102 end SUBROUTINE logwarning
103!=====================================================================
115!===============================================================
116 SUBROUTINE loginfo(msg)
117 character(len=*), INTENT(in) :: msg
118 call logall("Info", msg)
119 end SUBROUTINE loginfo
120!=====================================================================
133!===============================================================
134 SUBROUTINE logall(msgType, msg)
136 character(len=*), INTENT(in) :: msgType
137 character(len=*), INTENT(in) :: msg
138
139 INTEGER, dimension(8) :: timeVec
140
141 call date_and_time(values=timevec)
142 if (.NOT. initialized) then
143 write (*, 9000) timevec(5), timevec(6), timevec(7), msgtype, trim(msg);
144 return
145 end if
146 write (*, 9000) timevec(5), timevec(6), timevec(7), msgtype, trim(msg);
147 write (logfile%unit, 9000) timevec(5), timevec(6), timevec(7), msgtype, trim(msg);
1489000 FORMAT('[', i2.2, ':', i2.2, ":", i2.2, "][", a, "] ", a)
149 end SUBROUTINE logall
150end module loggermodule
subroutine closefile(thefile)
closeFile
subroutine openfilew(thefile, err)
openFileW
LoggerModule.
subroutine logwarning(msg)
LogError
subroutine loginfo(msg)
LogInfo
subroutine logall(msgtype, msg)
logAll
character(len=1024) logmessage
subroutine initlogger(log_file)
InitLogger
subroutine logerror(msg)
LogError
subroutine stoplogger()
StopLogger