Module: SignalWire::Core::LoggingConfig

Defined in:
lib/signalwire/core/logging_config.rb

Class Method Summary collapse

Class Method Details

.get_execution_modeString

Detect the SDK’s deployment environment based on well-known environment variables.

Returns:

  • (String)

    one of ‘cgi’, ‘lambda’, ‘google_cloud_function’, ‘azure_function’, or ‘server’.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/signalwire/core/logging_config.rb', line 28

def get_execution_mode
  return 'cgi' if env_set?('GATEWAY_INTERFACE')
  return 'lambda' if env_set?('AWS_LAMBDA_FUNCTION_NAME') || env_set?('LAMBDA_TASK_ROOT')

  if env_set?('FUNCTION_TARGET') ||
     env_set?('K_SERVICE') ||
     env_set?('GOOGLE_CLOUD_PROJECT')
    return 'google_cloud_function'
  end

  if env_set?('AZURE_FUNCTIONS_ENVIRONMENT') ||
     env_set?('FUNCTIONS_WORKER_RUNTIME') ||
     env_set?('AzureWebJobsStorage')
    return 'azure_function'
  end

  'server'
end