code: def setup_log_handlers(args, parser):
      log_handler = []
      if args.log_handler_script is not None:
          if not os.path.exists(args.log_handler_script):
              print(
                  "Error: no log handler script found, {}.".format(
                      args.log_handler_script
                  ),
                  file=sys.stderr,
              )
              sys.exit(1)
          log_script = SourceFileLoader(
              "log", args.log_handler_script
          ).load_module()
          try:
              log_handler.append(log_script.log_handler)
          except:
              print(
                  'Error: Invalid log handler script, {}. Expect python function "log_handler(msg)".'.format(
                      args.log_handler_script
                  ),
                  file=sys.stderr,
              )
              sys.exit(1)
  
      if args.log_service == "slack":
          slack_logger = logging.SlackLogger()
          log_handler.append(slack_logger.log_handler)
  
      elif args.wms_monitor or args.log_service == "wms":
          # Generate additional metadata for server
          metadata = generate_parser_metadata(parser, args)
          wms_logger = logging.WMSLogger(
              args.wms_monitor, args.wms_monitor_arg, metadata=metadata
          )
          log_handler.append(wms_logger.log_handler)
  
      return log_handler
  
imports: import os
  import re
  import sys
  from argparse import ArgumentDefaultsHelpFormatter
  from functools import partial
  from importlib.machinery import SourceFileLoader
  from pathlib import Path
  from typing import Set
  from snakemake_interface_executor_plugins.settings import ExecMode
  from snakemake_interface_storage_plugins.registry import StoragePluginRegistry
  import snakemake.common.argparse
  from snakemake import logging
  from snakemake.api import SnakemakeApi, _get_executor_plugin_registry, resolve_snakefile
  from snakemake.common import SNAKEFILE_CHOICES, __version__, async_run, get_appdirs, parse_key_value_arg
  from snakemake.dag import Batch
  from snakemake.exceptions import CliException, ResourceScopesException, print_exception
  from snakemake.resources import DefaultResources, ResourceScopes, eval_resource_expression, parse_resources
  from snakemake.settings import ChangeType, ConfigSettings, DAGSettings, DeploymentMethod, DeploymentSettings, ExecutionSettings, GroupSettings, NotebookEditMode, OutputSettings, PreemptibleRules, Quietness, RemoteExecutionSettings, RerunTrigger, ResourceSettings, SchedulingSettings, SharedFSUsage, StorageSettings, WorkflowSettings
  from snakemake.target_jobs import parse_target_jobs_cli_args
  from snakemake.utils import available_cpu_count, update_config
label_desc: Use image node_id 18 for calling a global function with example usage: setup_log_handlers(args, parser) and returns: log_handler