spx_logger.f90 Source File


Contents

Source Code


Source Code

!> 日志
module spx_logger

    use fffc_module, only: timer, nowtime
    implicit none

    private
    public :: lgr_obj, tmr_obj

    !> 日志
    type logger
        integer :: unit  !! 日志文件单元号
        character(7) :: filename = 'spx.log'  !! 日志文件名
        character(34) :: fmt = '(a, t20, ": ", *(g0.4, :, ", "))'  !! 数据日志格式
        character(34) :: longfmt = '(a, t40, ": ", *(g0.4, :, ", "))'  !! 数据日志长格式
    contains
        procedure :: init, destory
    end type logger

    type(logger) :: lgr_obj
    type(timer) :: tmr_obj

contains

    !> 初始化
    subroutine init(self)
        class(logger), intent(inout) :: self

        open (newunit=self%unit, file=self%filename, status='replace', action='write')
        write (self%unit, '(a)') nowtime()

    end subroutine init

    !> 关闭
    subroutine destory(self)
        class(logger), intent(inout) :: self

        close (self%unit)

    end subroutine destory

end module spx_logger