Class: Appium::Core::Logs

Inherits:
Object
  • Object
show all
Defined in:
lib/appium_lib_core/common/log.rb

Instance Method Summary collapse

Constructor Details

#initialize(bridge) ⇒ Logs

Returns a new instance of Logs.


18
19
20
# File 'lib/appium_lib_core/common/log.rb', line 18

def initialize(bridge)
  @bridge = bridge
end

Instance Method Details

#available_types[Hash]

Get a list of available log types

Examples:


@driver.logs.available_types # [:syslog, :crashlog, :performance]

Returns:

  • ([Hash])

    A list of available log types.


41
42
43
# File 'lib/appium_lib_core/common/log.rb', line 41

def available_types
  @bridge.available_log_types
end

#event(vendor:, event:) ⇒ nil

Logs a custom event. The event is available via Events#get or @driver.session_capabilities['events'] with eventTimings capabilities.

Examples:


@driver.logs.event vendor: 'appium', event: 'funEvent'
@driver.session_capabilities['events'] #=> {...., 'appium:funEvent' => 1572957315}

@driver.logs.event = { vendor: 'appium', event: 'anotherEvent' }
@driver.logs.events #=> {...., 'appium:funEvent' => [1572957315, 1572960305],
               #          'appium:anotherEvent' => 1572959315}

Parameters:

  • vendor (String)

    The vendor prefix for the event

  • event (String)

    The name of event

Returns:

  • (nil)

Since:

  • Appium 1.16.0


63
64
65
# File 'lib/appium_lib_core/common/log.rb', line 63

def event(vendor:, event:)
  @bridge.log_event vendor, event
end

#event=(log_event) ⇒ Object


67
68
69
70
71
# File 'lib/appium_lib_core/common/log.rb', line 67

def event=(log_event)
  raise ArgumentError('log_event should be Hash like { vendor: "appium", event: "funEvent"}') unless log_event.is_a?(Hash)

  event vendor: log_event[:vendor], event: log_event[:event]
end

#events(type = nil) ⇒ Hash

Returns events with filtering with 'type'. Defaults to all available events.

Examples:


@driver.logs.events #=> {}
@driver.logs.events #=> {'commands' => [{'cmd' => 123455, ....}], 'startTime' => 1572954894127, }

Parameters:

  • type (String) (defaults to: nil)

    The type of events to get

Returns:

  • (Hash)

Since:

  • Appium 1.16.0


84
85
86
# File 'lib/appium_lib_core/common/log.rb', line 84

def events(type = nil)
  @bridge.log_events(type)
end

#get(type) ⇒ [Selenium::WebDriver::LogEntry]

Returns A list of logs data.

Examples:


@driver.logs.get 'syslog' # []
@driver.logs.get :syslog # []

Parameters:

  • type (String|Hash)

    You can get particular type's logs.

Returns:

  • ([Selenium::WebDriver::LogEntry])

    A list of logs data.


30
31
32
# File 'lib/appium_lib_core/common/log.rb', line 30

def get(type)
  @bridge.log type
end