Skip to content

Commit

Permalink
Refactoring of logging sub-system.
Browse files Browse the repository at this point in the history
  • Loading branch information
interkosmos committed Mar 1, 2024
1 parent 6e27e98 commit ae17d55
Show file tree
Hide file tree
Showing 27 changed files with 619 additions and 506 deletions.
184 changes: 92 additions & 92 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
# FORD - FORD documentation generator.
#
# FFLAGS - Fortran compiler options.
# CLAGS - C compiler options.
# CFLAGS - C compiler options.
# PPFLAGS - Pre-processor options (must be empty for Intel oneAPI).
# ARFLAGS - Archiver options.
# LDFLAGS - Linker options.
Expand Down Expand Up @@ -145,8 +145,8 @@ DEBUG = -g -O0 -Wall -fcheck=all -fmax-errors=1
RELEASE = -mtune=native -O2

# Common build options.
FFLAGS = $(RELEASE) -ffree-line-length-0 -std=f2018
CFLAGS = $(RELEASE)
FFLAGS = $(RELEASE) -fPIC -ffree-line-length-0 -std=f2018
CFLAGS = $(RELEASE) -fPIC
PPFLAGS = -cpp -D__$(OS)__
ARFLAGS = -rcs
LDFLAGS = -I$(INCDIR) -J$(INCDIR) -L$(PREFIX)/lib -z execstack -z now
Expand Down Expand Up @@ -322,30 +322,30 @@ linux:
# ******************************************************************************

$(LIBFCURL): setup
cd vendor/fortran-curl/ && make CFLAGS="-fPIC $(CFLAGS)" FFLAGS="-fPIC $(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFCURL)"
cd vendor/fortran-curl/ && make CC=$(CC) FC=$(FC) CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFCURL)"
cp ./vendor/fortran-curl/*.mod $(INCDIR)/

$(LIBFLUA54): setup
cd vendor/fortran-lua54/ && make CFLAGS="-fPIC $(CFLAGS)" FFLAGS="-fPIC $(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFLUA54)"
cd vendor/fortran-lua54/ && make CC=$(CC) FC=$(FC) CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFLUA54)"
cp ./vendor/fortran-lua54/*.mod $(INCDIR)/

$(LIBFPCRE2): setup
cd vendor/fortran-pcre2/ && make CFLAGS="-fPIC $(CFLAGS)" FFLAGS="-fPIC $(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFPCRE2)"
cd vendor/fortran-pcre2/ && make CC=$(CC) FC=$(FC) CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFPCRE2)"
cp ./vendor/fortran-pcre2/*.mod $(INCDIR)/

$(LIBFSQLITE3): setup
cd vendor/fortran-sqlite3/ && make CFLAGS="-fPIC $(CFLAGS)" FFLAGS="-fPIC $(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFSQLITE3)"
cd vendor/fortran-sqlite3/ && make CC=$(CC) FC=$(FC) CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFSQLITE3)"
cp ./vendor/fortran-sqlite3/*.mod $(INCDIR)/

$(LIBFUNIX): setup
@echo "---"
@echo "--- Building for $(OS) ..."
@echo "---"
cd vendor/fortran-unix/ && make CFLAGS="-fPIC $(CFLAGS)" FFLAGS="-fPIC $(FFLAGS)" PREFIX="$(PREFIX)" PPFLAGS="$(PPFLAGS)" TARGET="../../$(LIBFUNIX)"
cd vendor/fortran-unix/ && make CC=$(CC) FC=$(FC) CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" PREFIX="$(PREFIX)" PPFLAGS="$(PPFLAGS)" TARGET="../../$(LIBFUNIX)"
cp ./vendor/fortran-unix/*.mod $(INCDIR)/

$(LIBFZ): setup
cd vendor/fortran-zlib/ && make CFLAGS="-fPIC $(CFLAGS)" FFLAGS="-fPIC $(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFZ)"
cd vendor/fortran-zlib/ && make CC=$(CC) FC=$(FC) CFLAGS="$(CFLAGS)" FFLAGS="$(FFLAGS)" PREFIX="$(PREFIX)" TARGET="../../$(LIBFZ)"
cp ./vendor/fortran-zlib/*.mod $(INCDIR)/

# ******************************************************************************
Expand All @@ -355,88 +355,88 @@ $(LIBFZ): setup
# ******************************************************************************

$(OBJ): $(SRC)
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_version.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_kind.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_platform.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_ascii.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_const.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_error.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_string.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_type.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_format.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_ansi.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_env.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_util.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_time.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_timer.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_base64.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_path.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_file.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_hash.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_hash_table.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_unit.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_id.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_uuid.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_arg.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_signal.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_system.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_pipe.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_tty.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_sem.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_mutex.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_dp.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_fifo.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_node.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_sensor.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_target.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_response.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_request.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_observ.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_log.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_job.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_plot.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_report.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_regex.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_sync.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_beat.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_mqueue.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_logger.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_test.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_nml.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) $(INCHDF5) -c src/dm_hdf5.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_sql.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_db.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_z.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_person.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_mail.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_http.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_mime.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_api.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_rpc.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_mqtt.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_cgi.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_fcgi.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_block.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_csv.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_json.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_jsonl.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_html.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_atom.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_cgi_router.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_la.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_transform.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_geocom_error.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_geocom_type.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_geocom_api.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_geocom.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_lua.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_lua_api.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_lua_geocom.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_lua_lib.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_config.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_rts.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dm_mqueue_util.f90
$(FC) -fPIC $(FFLAGS) $(LDFLAGS) -c src/dmpack.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_version.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_kind.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_platform.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_ascii.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_const.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_error.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_string.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_type.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_format.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_ansi.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_env.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_util.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_time.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_timer.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_base64.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_path.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_file.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_hash.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_hash_table.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_unit.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_id.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_uuid.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_arg.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_signal.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_system.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_pipe.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_tty.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_sem.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_mutex.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_dp.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_fifo.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_node.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_sensor.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_target.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_response.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_request.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_observ.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_log.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_job.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_plot.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_report.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_regex.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_sync.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_beat.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_mqueue.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_logger.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_test.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_nml.f90
$(FC) $(FFLAGS) $(LDFLAGS) $(INCHDF5) -c src/dm_hdf5.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_sql.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_db.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_z.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_person.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_mail.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_http.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_mime.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_api.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_rpc.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_mqtt.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_cgi.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_fcgi.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_block.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_csv.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_json.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_jsonl.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_html.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_atom.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_cgi_router.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_la.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_transform.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_geocom_error.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_geocom_type.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_geocom_api.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_geocom.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_lua.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_lua_api.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_lua_geocom.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_lua_lib.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_config.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_rts.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dm_mqueue_util.f90
$(FC) $(FFLAGS) $(LDFLAGS) -c src/dmpack.f90

# Static library `libdmpack.a`.
$(TARGET): $(LIBF) $(OBJ)
Expand All @@ -451,7 +451,7 @@ $(TARGET): $(LIBF) $(OBJ)

# Shared library `libdmpack.so`.
$(SHARED): $(TARGET)
$(FC) -fPIC -shared $(FFLAGS) $(LDFLAGS) -o $(SHARED) -Wl,--whole-archive $(TARGET) -Wl,--no-whole-archive $(LIBSHARED) $(LDLIBS)
$(FC) $(FFLAGS) $(LDFLAGS) -shared -o $(SHARED) -Wl,--whole-archive $(TARGET) -Wl,--no-whole-archive $(LIBSHARED) $(LDLIBS)

# ******************************************************************************
#
Expand Down
38 changes: 19 additions & 19 deletions app/dmbeat.f90
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
! Licence: ISC
program dmbeat
!! Heartbeat emitter, sends status messages to the RPC API.
use :: dmpack, dm_log => dm_logger_log
use :: dmpack
implicit none (type, external)

character(len=*), parameter :: APP_NAME = 'dmbeat'
Expand Down Expand Up @@ -58,7 +58,7 @@ program dmbeat
rc = dm_rpc_init()

if (dm_is_error(rc)) then
call dm_log(LOG_ERROR, 'failed to initialize libcurl', error=rc)
call dm_log_error('failed to initialize libcurl', error=rc)
call dm_stop(1)
end if

Expand Down Expand Up @@ -195,7 +195,7 @@ subroutine run(app)
type(rpc_response_type) :: response
type(timer_type) :: timer

call dm_log(LOG_INFO, 'started ' // app%name)
call dm_log_info('started ' // app%name)

! Client and library version.
client = dm_version_to_string(APP_NAME, APP_MAJOR, APP_MINOR, APP_PATCH, library=.true.)
Expand All @@ -211,7 +211,7 @@ subroutine run(app)

emit_loop: do
call dm_timer_start(timer)
call dm_log(LOG_DEBUG, 'emitting beat for node ' // trim(app%node) // ' to host ' // app%host)
call dm_log_debug('emitting beat for node ' // trim(app%node) // ' to host ' // app%host)

! Create new heartbeat.
beat = beat_type(node_id = app%node, &
Expand All @@ -234,42 +234,42 @@ subroutine run(app)
url = url)

if (dm_is_error(rc)) then
call dm_log(LOG_DEBUG, 'failed to send beat to host ' // app%host, error=rc)
call dm_log_debug('failed to send beat to host ' // app%host, error=rc)
end if

last_error = rc

code_select: &
select case (response%code)
case (0)
call dm_log(LOG_WARNING, 'connection to host ' // trim(app%host) // ' failed: ' // &
response%error_message, error=rc)
call dm_log_warning('connection to host ' // trim(app%host) // ' failed: ' // &
response%error_message, error=rc)

case (HTTP_CREATED)
call dm_log(LOG_DEBUG, 'beat accepted by host ' // app%host)
call dm_log_debug('beat accepted by host ' // app%host)

case (HTTP_UNAUTHORIZED)
call dm_log(LOG_ERROR, 'unauthorized access on host ' // app%host, error=E_RPC_AUTH)
call dm_log_error('unauthorized access on host ' // app%host, error=E_RPC_AUTH)

case (HTTP_INTERNAL_SERVER_ERROR)
call dm_log(LOG_ERROR, 'internal server error on host ' // app%host, error=E_RPC_SERVER)
call dm_log_error('internal server error on host ' // app%host, error=E_RPC_SERVER)

case (HTTP_BAD_GATEWAY)
call dm_log(LOG_ERROR, 'bad gateway on host ' // app%host, error=E_RPC_CONNECT)
call dm_log_error('bad gateway on host ' // app%host, error=E_RPC_CONNECT)

case default
! Log response from api message if available.
if (response%content_type == MIME_TEXT) then
if (dm_is_ok(dm_api_status_from_string(api, response%payload))) then
call dm_log(LOG_ERROR, 'server error on host ' // trim(app%host) // &
' (HTTP ' // dm_itoa(response%code) // '): ' // &
api%message, error=api%error)
call dm_log_error('server error on host ' // trim(app%host) // &
' (HTTP ' // dm_itoa(response%code) // '): ' // &
api%message, error=api%error)
exit code_select
end if
end if

call dm_log(LOG_WARNING, 'API call to host ' // trim(app%host) // ' failed (HTTP ' // &
dm_itoa(response%code) // ')', error=E_RPC_API)
call dm_log_warning('API call to host ' // trim(app%host) // ' failed (HTTP ' // &
dm_itoa(response%code) // ')', error=E_RPC_API)
end select code_select

if (app%count > 0) then
Expand All @@ -278,11 +278,11 @@ subroutine run(app)
end if

t = max(0, int(app%interval - dm_timer_stop(timer)))
call dm_log(LOG_DEBUG, 'next beat in ' // dm_itoa(t) // ' sec')
call dm_log_debug('next beat in ' // dm_itoa(t) // ' sec')
call dm_sleep(t)
end do emit_loop

call dm_log(LOG_DEBUG, 'finished transmission')
call dm_log_debug('finished transmission')
end subroutine run

subroutine signal_handler(signum) bind(c)
Expand All @@ -293,7 +293,7 @@ subroutine signal_handler(signum) bind(c)

select case (signum)
case default
call dm_log(LOG_INFO, 'exit on signal ' // dm_itoa(signum))
call dm_log_info('exit on signal ' // dm_itoa(signum))
call dm_rpc_destroy()
call dm_stop(0)
end select
Expand Down
Loading

0 comments on commit ae17d55

Please sign in to comment.