Skip to content

Commit

Permalink
Refactoring of logger.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Oct 10, 2024
1 parent 425891e commit bdb782b
Show file tree
Hide file tree
Showing 17 changed files with 20 additions and 20 deletions.
2 changes: 1 addition & 1 deletion app/dmbeat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ program dmbeat
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmbot.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ program dmbot
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, & ! Name of logger process.
node_id = app%node, & ! Node id.
source = app%name, & ! Log source.
Expand Down
2 changes: 1 addition & 1 deletion app/dmdb.f90
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ program dmdb
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmfs.f90
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ program dmfs
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmgrc.f90
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ program dmgrc
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmlog.f90
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ program dmlog
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name=app%logger, ipc=.true., verbose=app%verbose)

! Prepare and send log.
Expand Down
2 changes: 1 addition & 1 deletion app/dmlogger.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ program dmlogger

init_block: block
! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%name, & ! Name of global logger.
node_id = app%node, & ! Sensor node id.
source = app%name, & ! Application name.
Expand Down
2 changes: 1 addition & 1 deletion app/dmlua.f90
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ program dmlua
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmpipe.f90
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ program dmpipe
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmrecv.f90
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ program dmrecv
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmsend.f90
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ program dmsend
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmserial.f90
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ program dmserial
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, &
node_id = app%node, &
source = app%name, &
Expand Down
2 changes: 1 addition & 1 deletion app/dmsync.f90
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ program dmsync
if (dm_is_error(rc)) call dm_stop(STOP_FAILURE)

! Initialise logger.
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name = app%logger, & ! Name of logger process.
node_id = app%node, & ! Node id.
source = app%name, & ! Log source.
Expand Down
2 changes: 1 addition & 1 deletion src/dm_jabber.f90
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ integer function dm_jabber_create(jabber, log_level) result(rc)
! Set log level.
ll = JABBER_LL_NONE
if (present(log_level)) ll = log_level
if (ll < JABBER_LL_NONE .or. ll> JABBER_LL_ERROR) return
if (ll < JABBER_LL_NONE .or. ll > JABBER_LL_ERROR) return

! Enable logging.
if (ll /= JABBER_LL_NONE) log = xmpp_get_default_logger(ll)
Expand Down
8 changes: 4 additions & 4 deletions src/dm_logger.f90
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ module dm_logger
!! ```fortran
!! class(logger_class), pointer :: logger
!!
!! logger => dm_logger_get()
!! logger => dm_logger_get_default()
!! call logger%configure(name='dmlogger', ipc=.true., verbose=.true.)
!! call logger%error('log message')
!! ```
Expand Down Expand Up @@ -74,7 +74,7 @@ module dm_logger
class(logger_class), allocatable, target, save :: MODULE_LOGGER

! Public procedures.
public :: dm_logger_get
public :: dm_logger_get_default

! Private procedures.
private :: logger_configure
Expand All @@ -93,7 +93,7 @@ module dm_logger
! ******************************************************************
! PUBLIC PROCEDURES.
! ******************************************************************
function dm_logger_get() result(logger)
function dm_logger_get_default() result(logger)
!! Returns pointer to global logger. The function allocates the logger
!! if it does not exist yet.
class(logger_class), pointer :: logger !! Pointer to logger object.
Expand All @@ -108,7 +108,7 @@ function dm_logger_get() result(logger)
end if

logger => MODULE_LOGGER
end function dm_logger_get
end function dm_logger_get_default

! ******************************************************************
! PRIVATE CLASS METHODS.
Expand Down
2 changes: 1 addition & 1 deletion src/dm_mqueue_util.f90
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ integer function mqueue_forward_observ(observ, name, blocking, allow_self, verbo
! Enable logging.
verbose_ = .true.
if (present(verbose)) verbose_ = verbose
if (verbose_) logger => dm_logger_get()
if (verbose_) logger => dm_logger_get_default()

do
! Increase the receiver index.
Expand Down
2 changes: 1 addition & 1 deletion test/dmtestlogger.f90
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ logical function test01() result(stat)
log1%error = TEST_ERROR

print *, 'Initialising logger ...'
logger => dm_logger_get()
logger => dm_logger_get_default()
call logger%configure(name=LOGGER_NAME, debug=.true., ipc=.true., no_color=.true.)

print *, 'Opening log message queue ...'
Expand Down

0 comments on commit bdb782b

Please sign in to comment.