log_format_message Function

public function log_format_message(level, tag, message, colour, datetime) result(msg)

Arguments

Type IntentOptional AttributesName
integer, intent(in) :: level
character(len=*), intent(in) :: tag
character(len=*), intent(in) :: message
logical, intent(in), optional :: colour
logical, intent(in), optional :: datetime

Return Value character(len=23)


Calls

proc~~log_format_message~~CallsGraph proc~log_format_message log_format_message proc~date_time_str date_time_str proc~log_format_message->proc~date_time_str proc~colourise colourise proc~log_format_message->proc~colourise proc~string_index string_index proc~colourise->proc~string_index

Called by

proc~~log_format_message~~CalledByGraph proc~log_format_message log_format_message proc~log_progress log_progress proc~log_progress->proc~log_format_message proc~log_message log_message proc~log_message->proc~log_format_message proc~log_info log_info proc~log_info->proc~log_message proc~log_error log_error proc~log_error->proc~log_message proc~log_debug log_debug proc~log_debug->proc~log_message proc~log_warn log_warn proc~log_warn->proc~log_message proc~time_process_day time_process_day proc~time_process_day->proc~log_progress proc~time_process_day->proc~log_debug proc~reservoir_process reservoir_process proc~time_process_day->proc~reservoir_process proc~management_total_demand management_total_demand proc~time_process_day->proc~management_total_demand proc~management_external_supply management_external_supply proc~time_process_day->proc~management_external_supply proc~evapotranspiration_radiation evapotranspiration_radiation proc~time_process_day->proc~evapotranspiration_radiation proc~input_nc_read_climate input_nc_read_climate proc~time_process_day->proc~input_nc_read_climate proc~runsubbasin runsubbasin proc~time_process_day->proc~runsubbasin proc~river_route_add river_route_add proc~time_process_day->proc~river_route_add proc~river_route river_route proc~time_process_day->proc~river_route proc~subbasin_read_climate subbasin_read_climate proc~time_process_day->proc~subbasin_read_climate proc~output_day output_day proc~time_process_day->proc~output_day proc~output_check_requested_vars output_check_requested_vars proc~output_check_requested_vars->proc~log_error proc~output_initialise_time output_initialise_time proc~output_initialise_time->proc~log_error proc~hydrotope_subbasin_division hydrotope_subbasin_division proc~hydrotope_subbasin_division->proc~log_info proc~hydrotope_subbasin_division->proc~log_error proc~catchment_initialise_parameters catchment_initialise_parameters proc~catchment_initialise_parameters->proc~log_warn proc~catchment_read_subcatch_params catchment_read_subcatch_params proc~catchment_initialise_parameters->proc~catchment_read_subcatch_params proc~input_count_rows input_count_rows proc~input_count_rows->proc~log_error proc~read_logical_column read_logical_column proc~read_logical_column->proc~log_error proc~input_error_column_not_found input_error_column_not_found proc~read_logical_column->proc~input_error_column_not_found proc~input_type_conversion_error input_type_conversion_error proc~read_logical_column->proc~input_type_conversion_error proc~header_column_index header_column_index proc~read_logical_column->proc~header_column_index proc~output_write_space_time_csv output_write_space_time_csv proc~output_write_space_time_csv->proc~log_error proc~output_array_to_csv output_array_to_csv proc~output_write_space_time_csv->proc~output_array_to_csv proc~read_string_column read_string_column proc~read_string_column->proc~log_error proc~read_string_column->proc~input_error_column_not_found proc~read_string_column->proc~header_column_index proc~management_read_ctrl management_read_ctrl proc~management_read_ctrl->proc~log_info proc~management_read_ctrl->proc~log_error proc~management_read_ctrl->proc~input_count_rows proc~management_read_ctrl->proc~read_string_column proc~read_integer_column read_integer_column proc~management_read_ctrl->proc~read_integer_column proc~read_real_column read_real_column proc~management_read_ctrl->proc~read_real_column proc~input_open_file input_open_file proc~management_read_ctrl->proc~input_open_file proc~management_user_pointer management_user_pointer proc~management_user_pointer->proc~log_error proc~output_initialise_user_input output_initialise_user_input proc~output_initialise_user_input->proc~log_error proc~extend_unique_string extend_unique_string proc~output_initialise_user_input->proc~extend_unique_string proc~open_file open_file proc~output_initialise_user_input->proc~open_file proc~log_create log_create proc~output_initialise_user_input->proc~log_create proc~get_config_fid get_config_fid proc~output_initialise_user_input->proc~get_config_fid proc~input_nc_check_dims input_nc_check_dims proc~input_nc_check_dims->proc~log_error proc~input_nc_check_dims->proc~log_debug proc~input_nc_check_error input_nc_check_error proc~input_nc_check_dims->proc~input_nc_check_error proc~soil_read_input soil_read_input proc~soil_read_input->proc~log_info proc~soil_read_input->proc~log_error proc~soil_read_input->proc~log_debug proc~soil_read_input->proc~read_string_column proc~check_range check_range proc~soil_read_input->proc~check_range proc~soil_read_input->proc~open_file proc~input_nc_check_error->proc~log_error proc~input_error_column_not_found->proc~log_error proc~reservoir_process->proc~log_error proc~read_integer_column->proc~log_error proc~read_integer_column->proc~input_error_column_not_found proc~read_integer_column->proc~input_type_conversion_error proc~check_int_range check_int_range proc~read_integer_column->proc~check_int_range proc~read_integer_column->proc~header_column_index proc~input_nc_find_time input_nc_find_time proc~input_nc_find_time->proc~log_error proc~input_nc_find_time->proc~log_debug proc~input_nc_check_attr input_nc_check_attr proc~input_nc_check_attr->proc~log_debug proc~input_type_conversion_error->proc~log_error proc~time_finish_year time_finish_year proc~time_finish_year->proc~log_debug proc~output_nashsutcliffe_efficiency output_nashsutcliffe_efficiency proc~time_finish_year->proc~output_nashsutcliffe_efficiency proc~output_year output_year proc~time_finish_year->proc~output_year proc~check_range->proc~log_error proc~check_range->proc~log_warn proc~out_of_range_error out_of_range_error proc~check_range->proc~out_of_range_error proc~catchment_read_subcatch_params->proc~log_debug proc~catchment_read_subcatch_params->proc~read_integer_column proc~catchment_read_subcatch_params->proc~read_real_column proc~soil_initialise soil_initialise proc~soil_initialise->proc~log_error proc~soil_initialise->proc~log_debug proc~soil_initialise->proc~input_count_rows proc~soil_initialise->proc~soil_read_input proc~output_register_hydrotope_var output_register_hydrotope_var proc~soil_initialise->proc~output_register_hydrotope_var proc~soil_initialise->proc~get_config_fid proc~soil_initialise->proc~input_open_file proc~input_nc_convert_coordinates input_nc_convert_coordinates proc~input_nc_convert_coordinates->proc~log_error proc~input_nc_convert_coordinates->proc~log_debug proc~reservoir_read_month_file reservoir_read_month_file proc~reservoir_read_month_file->proc~log_warn proc~reservoir_read_month_file->proc~read_real_column proc~reservoir_read_month_file->proc~input_open_file proc~time_process_years time_process_years proc~time_process_years->proc~log_info proc~time_process_years->proc~time_finish_year proc~time_process_month time_process_month proc~time_process_years->proc~time_process_month proc~time_initialise_year time_initialise_year proc~time_process_years->proc~time_initialise_year proc~read_real_column->proc~log_error proc~read_real_column->proc~input_error_column_not_found proc~read_real_column->proc~input_type_conversion_error proc~read_real_column->proc~check_range proc~read_real_column->proc~header_column_index proc~input_nc_check_grid input_nc_check_grid proc~input_nc_check_grid->proc~log_debug proc~input_nc_check_grid->proc~log_warn proc~input_nc_check_grid->proc~input_open_file proc~management_initialise management_initialise proc~management_initialise->proc~log_info proc~management_initialise->proc~log_debug proc~management_initialise->proc~management_read_ctrl proc~management_initialise->proc~log_create proc~management_read_wu_inout management_read_wu_inout proc~management_initialise->proc~management_read_wu_inout proc~extend_unique_string->proc~log_error proc~management_total_demand->proc~log_warn proc~management_total_demand->proc~management_user_pointer proc~time_process_month->proc~log_debug proc~time_process_month->proc~time_process_day proc~output_month output_month proc~time_process_month->proc~output_month proc~management_external_supply->proc~log_warn proc~management_external_supply->proc~management_user_pointer proc~input_nc_initialise input_nc_initialise proc~input_nc_initialise->proc~log_info proc~input_nc_initialise->proc~log_debug proc~input_nc_initialise->proc~input_nc_check_dims proc~input_nc_initialise->proc~input_nc_check_error proc~input_nc_initialise->proc~input_nc_find_time proc~input_nc_initialise->proc~input_nc_check_attr proc~input_nc_initialise->proc~input_nc_convert_coordinates proc~input_nc_initialise->proc~input_nc_check_grid proc~input_nc_offset_time input_nc_offset_time proc~input_nc_initialise->proc~input_nc_offset_time proc~input_nc_check_missing input_nc_check_missing proc~input_nc_initialise->proc~input_nc_check_missing proc~input_nc_read_grid input_nc_read_grid proc~input_nc_initialise->proc~input_nc_read_grid proc~input_nc_initialise->proc~get_config_fid proc~print_help print_help proc~print_help->proc~log_error proc~open_file->proc~log_error proc~crop_read_input crop_read_input proc~crop_read_input->proc~log_error proc~crop_read_input->proc~log_debug proc~crop_read_input->proc~read_string_column proc~crop_read_input->proc~read_integer_column proc~crop_read_input->proc~read_real_column proc~output_nashsutcliffe_efficiency->proc~log_debug proc~landuse_initialise landuse_initialise proc~landuse_initialise->proc~log_debug proc~landuse_initialise->proc~input_count_rows proc~landuse_read_input landuse_read_input proc~landuse_initialise->proc~landuse_read_input proc~landuse_initialise->proc~get_config_fid proc~landuse_initialise->proc~input_open_file proc~management_transfer_out management_transfer_out proc~management_transfer_out->proc~log_warn proc~management_transfer_out->proc~management_user_pointer proc~input_nc_offset_time->proc~log_error proc~hydrotope_read_input hydrotope_read_input proc~hydrotope_read_input->proc~log_info proc~hydrotope_read_input->proc~input_count_rows proc~hydrotope_read_input->proc~read_integer_column proc~hydrotope_read_input->proc~read_real_column proc~hydrotope_read_input->proc~input_open_file proc~reservoir_initialise reservoir_initialise proc~reservoir_initialise->proc~log_info proc~reservoir_initialise->proc~log_warn proc~reservoir_initialise->proc~reservoir_read_month_file proc~reservoir_read_storage_file reservoir_read_storage_file proc~reservoir_initialise->proc~reservoir_read_storage_file proc~reservoir_read_control_file reservoir_read_control_file proc~reservoir_initialise->proc~reservoir_read_control_file proc~reservoir_initialise->proc~get_config_fid proc~reservoir_open_output reservoir_open_output proc~reservoir_initialise->proc~reservoir_open_output proc~out_of_range_error->proc~log_error proc~check_int_range->proc~log_error proc~check_int_range->proc~log_warn proc~check_int_range->proc~out_of_range_error proc~evapotranspiration_radiation->proc~log_warn proc~initialise initialise proc~initialise->proc~log_info proc~initialise->proc~catchment_initialise_parameters proc~initialise->proc~output_initialise_user_input proc~initialise->proc~soil_initialise proc~initialise->proc~management_initialise proc~initialise->proc~input_nc_initialise proc~initialise->proc~crop_read_input proc~initialise->proc~landuse_initialise proc~initialise->proc~reservoir_initialise proc~evapotranspiration_initialise evapotranspiration_initialise proc~initialise->proc~evapotranspiration_initialise proc~output_initialise output_initialise proc~initialise->proc~output_initialise proc~print_module_parameters print_module_parameters proc~initialise->proc~print_module_parameters proc~parse_commandline_arguments parse_commandline_arguments proc~initialise->proc~parse_commandline_arguments proc~crop_initialise crop_initialise proc~initialise->proc~crop_initialise proc~hydrotope_initialise hydrotope_initialise proc~initialise->proc~hydrotope_initialise proc~subbasin_initialise subbasin_initialise proc~initialise->proc~subbasin_initialise proc~initialise->proc~get_config_fid proc~snow_initialise snow_initialise proc~initialise->proc~snow_initialise proc~vegetation_initialise vegetation_initialise proc~initialise->proc~vegetation_initialise proc~groundwater_initialise groundwater_initialise proc~initialise->proc~groundwater_initialise proc~input_initialise input_initialise proc~initialise->proc~input_initialise proc~time_initialise time_initialise proc~initialise->proc~time_initialise proc~erosion_initialise erosion_initialise proc~initialise->proc~erosion_initialise proc~nutrient_initialise nutrient_initialise proc~initialise->proc~nutrient_initialise proc~catchment_initialise catchment_initialise proc~initialise->proc~catchment_initialise proc~river_initialise river_initialise proc~initialise->proc~river_initialise proc~input_nc_check_missing->proc~log_error proc~input_nc_check_missing->proc~log_debug proc~input_nc_check_missing->proc~log_warn proc~input_nc_check_missing->proc~input_nc_check_error proc~output_register_var output_register_var proc~output_register_var->proc~log_error proc~landuse_index landuse_index proc~landuse_index->proc~log_error proc~river_muskingum_routing river_muskingum_routing proc~river_muskingum_routing->proc~log_warn proc~input_nc_read_climate->proc~log_debug proc~input_nc_weighted_mean input_nc_weighted_mean proc~input_nc_read_climate->proc~input_nc_weighted_mean proc~output_initialise_labelled output_initialise_labelled proc~output_initialise_labelled->proc~log_error proc~output_initialise_labelled->proc~read_string_column proc~has_column has_column proc~output_initialise_labelled->proc~has_column proc~evapotranspiration_initialise->proc~log_debug proc~evapotranspiration_read_input evapotranspiration_read_input proc~evapotranspiration_initialise->proc~evapotranspiration_read_input proc~evapotranspiration_initialise->proc~output_register_hydrotope_var proc~evapotranspiration_initialise->proc~get_config_fid proc~output_array_to_csv->proc~log_error proc~snow_read_input snow_read_input proc~snow_read_input->proc~read_real_column proc~reservoir_read_storage_file->proc~read_real_column proc~reservoir_read_storage_file->proc~input_open_file proc~evapotranspiration_read_input->proc~read_real_column proc~runsubbasin->proc~management_transfer_out proc~landuse_is_forest landuse_is_forest proc~runsubbasin->proc~landuse_is_forest proc~hydrotope_process hydrotope_process proc~runsubbasin->proc~hydrotope_process proc~landuse_is_cropland landuse_is_cropland proc~runsubbasin->proc~landuse_is_cropland proc~output_register_hydrotope_var->proc~output_register_var proc~output_initialise->proc~output_initialise_time proc~output_initialise_storage output_initialise_storage proc~output_initialise->proc~output_initialise_storage proc~print_module_parameters->proc~print_help proc~output_open_file output_open_file proc~output_open_file->proc~open_file proc~river_route_add->proc~management_transfer_out proc~groundwater_read_input groundwater_read_input proc~groundwater_read_input->proc~read_real_column proc~parse_commandline_arguments->proc~print_help proc~output_initialise_storage->proc~output_check_requested_vars proc~output_initialise_storage->proc~output_initialise_labelled proc~output_open_files output_open_files proc~output_initialise_storage->proc~output_open_files proc~input_nc_close input_nc_close proc~input_nc_close->proc~input_nc_check_error proc~landuse_is_natural_vegetation landuse_is_natural_vegetation proc~landuse_is_natural_vegetation->proc~landuse_index proc~river_route->proc~river_muskingum_routing proc~crop_initialise->proc~input_count_rows proc~crop_initialise->proc~output_register_hydrotope_var proc~crop_read_management_input crop_read_management_input proc~crop_initialise->proc~crop_read_management_input proc~crop_initialise->proc~get_config_fid proc~crop_initialise->proc~input_open_file proc~river_read_input river_read_input proc~river_read_input->proc~read_real_column proc~log_create->proc~open_file proc~subbasin_read_routing subbasin_read_routing proc~subbasin_read_routing->proc~input_count_rows proc~subbasin_read_routing->proc~read_integer_column proc~subbasin_read_routing->proc~input_open_file proc~subbasin_read_climate->proc~read_real_column proc~output_register_subbasin_var output_register_subbasin_var proc~output_register_subbasin_var->proc~output_register_var proc~management_distribribute management_distribribute proc~management_distribribute->proc~management_user_pointer proc~hydrotope_initialise->proc~hydrotope_subbasin_division proc~hydrotope_initialise->proc~hydrotope_read_input proc~hydrotope_initialise->proc~output_register_hydrotope_var proc~hydrotope_initialise->proc~output_register_subbasin_var proc~landuse_is_forest->proc~landuse_index proc~vegetation_water_stress vegetation_water_stress proc~vegetation_water_stress->proc~management_user_pointer proc~vegetation_water_stress->proc~landuse_is_cropland proc~input_nc_read_grid->proc~check_range proc~input_nc_read_grid->proc~input_open_file proc~crop_read_management_input->proc~read_integer_column proc~crop_read_management_input->proc~read_real_column proc~subbasin_read_input subbasin_read_input proc~subbasin_read_input->proc~read_string_column proc~subbasin_read_input->proc~read_integer_column proc~subbasin_read_input->proc~read_real_column proc~landuse_read_input->proc~read_integer_column proc~landuse_read_input->proc~read_real_column proc~subbasin_initialise->proc~input_count_rows proc~subbasin_initialise->proc~subbasin_read_routing proc~subbasin_initialise->proc~output_register_subbasin_var proc~subbasin_initialise->proc~subbasin_read_input proc~subbasin_initialise->proc~header_column_index proc~subbasin_initialise->proc~get_config_fid proc~subbasin_initialise->proc~input_open_file proc~subbasin_allocate_obs_discharge subbasin_allocate_obs_discharge proc~subbasin_initialise->proc~subbasin_allocate_obs_discharge proc~hydrotope_process->proc~management_user_pointer proc~hydrotope_process->proc~landuse_index proc~hydrotope_process->proc~landuse_is_natural_vegetation proc~hydrotope_process->proc~landuse_is_forest proc~hydrotope_process->proc~landuse_is_cropland proc~vegetation_process vegetation_process proc~hydrotope_process->proc~vegetation_process proc~crop_process crop_process proc~hydrotope_process->proc~crop_process program~swim swim program~swim->proc~time_process_years program~swim->proc~initialise proc~terminate terminate program~swim->proc~terminate proc~output_write_time output_write_time proc~output_write_time->proc~output_write_space_time_csv proc~input_nc_weighted_mean->proc~input_nc_check_error proc~landuse_is_cropland->proc~landuse_index proc~header_column_index->proc~input_error_column_not_found proc~reservoir_read_control_file->proc~input_count_rows proc~reservoir_read_control_file->proc~read_logical_column proc~reservoir_read_control_file->proc~read_string_column proc~reservoir_read_control_file->proc~read_integer_column proc~reservoir_read_control_file->proc~read_real_column proc~reservoir_read_control_file->proc~input_open_file proc~get_config_fid->proc~open_file proc~erosion_read_input erosion_read_input proc~erosion_read_input->proc~read_real_column proc~input_open_file->proc~open_file proc~management_read_time_series management_read_time_series proc~management_read_time_series->proc~read_real_column proc~management_read_time_series->proc~open_file proc~time_initialise_year->proc~read_real_column proc~output_open_files->proc~output_open_file proc~management_write_user_output management_write_user_output proc~management_write_user_output->proc~output_open_file proc~snow_initialise->proc~snow_read_input proc~snow_initialise->proc~output_register_hydrotope_var proc~snow_initialise->proc~output_register_subbasin_var proc~snow_initialise->proc~get_config_fid proc~vegetation_initialise->proc~output_register_hydrotope_var proc~vegetation_initialise->proc~get_config_fid proc~output_write_daily output_write_daily proc~output_write_daily->proc~output_write_time proc~output_write_annual output_write_annual proc~output_write_annual->proc~output_write_time proc~groundwater_initialise->proc~output_register_hydrotope_var proc~groundwater_initialise->proc~groundwater_read_input proc~groundwater_initialise->proc~output_register_subbasin_var proc~groundwater_initialise->proc~get_config_fid proc~output_write_monthly output_write_monthly proc~output_write_monthly->proc~output_write_time proc~terminate->proc~input_nc_close proc~terminate->proc~get_config_fid proc~terminate->proc~management_write_user_output proc~input_initialise->proc~get_config_fid proc~has_column->proc~header_column_index proc~time_initialise->proc~get_config_fid proc~erosion_initialise->proc~get_config_fid proc~erosion_initialise->proc~erosion_read_input proc~nutrient_initialise->proc~get_config_fid proc~catchment_initialise->proc~get_config_fid proc~catchment_initialise->proc~input_open_file proc~vegetation_process->proc~vegetation_water_stress proc~vegetation_temperature_stress vegetation_temperature_stress proc~vegetation_process->proc~vegetation_temperature_stress proc~river_initialise->proc~river_read_input proc~river_initialise->proc~output_register_subbasin_var proc~river_initialise->proc~get_config_fid proc~management_read_wu_inout->proc~management_read_time_series proc~reservoir_open_output->proc~output_open_file proc~crop_process->proc~vegetation_water_stress proc~crop_growth crop_growth proc~crop_process->proc~crop_growth proc~vegetation_temperature_stress->proc~landuse_is_cropland proc~crop_growth->proc~vegetation_temperature_stress proc~output_year->proc~output_write_daily proc~output_year->proc~output_write_annual proc~output_year->proc~output_write_monthly proc~output_day->proc~output_write_daily proc~subbasin_allocate_obs_discharge->proc~has_column proc~output_month->proc~output_write_daily proc~output_month->proc~output_write_monthly

Contents

Source Code


Source Code

  function log_format_message(level, tag, message, colour, datetime) result(msg)
    ! Format log message with tag, message and optionally coloured level

    ! The level for which to get the designator
    integer, intent(in) :: level
    character(len=*), intent(in) :: tag
    character(len=*), intent(in) :: message
    ! Whether to colourise the level tag, should only be done if the designator is
    ! printed to the terminal. Defaults to `.true.`.
    ! Whether to add datetime stamp at beginning, defaults to .true.
    logical, intent(in), optional :: colour, datetime
    character(len=23+len(tag)+2+21+len(message)) :: msg
    character(len=21) :: levelstr, dt
    character(len=len(tag)+2) :: tagb
    integer :: descriminator
    logical :: col

    if (present(colour)) then
      col = colour
    else
      col = .true.
    end if
    descriminator = level/10
    if (descriminator < 1) then
        levelstr = ''
    else if (descriminator < 2) then
        levelstr = '<DEBUG>'
      if (col) levelstr = colourise(levelstr, 'cyan')
    else if (descriminator < 3) then
        levelstr = '<INFO>'
      if (col) levelstr = colourise(levelstr, 'blue')
    else if (descriminator < 4) then
        levelstr = '<WARNING>'
      if (col) levelstr = colourise(levelstr, 'yellow')
    else if (descriminator < 5) then
        levelstr = '<ERROR>'
      if (col) levelstr = colourise(levelstr, 'red')
    end if
    dt = ''
    if (present(datetime)) then
      if (datetime) dt = date_time_str()
    else
      dt = "["//date_time_str()//"]"
    end if
    tagb = tag
    if (len_trim(tag) > 0) tagb = '['//tag//']'
    ! put together
    write(msg, "(3a,(1x,a))") trim(levelstr), trim(dt), trim(tagb), trim(message)
  end function log_format_message