Skip to content

Commit

Permalink
[rb] Extend RBS support for logger and log entry (#13192)
Browse files Browse the repository at this point in the history
* Extend RBS support for logger and log entry

* Update allowed to match the instance type

* Change as_json to untyped and nillable

---------

Co-authored-by: aguspe <agustin.pe94@gmail.com>
Co-authored-by: Titus Fortner <titusfortner@users.noreply.github.com>
  • Loading branch information
3 people authored Nov 27, 2023
1 parent c806757 commit 36585d1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
2 changes: 2 additions & 0 deletions rb/Steepfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
target :lib do
signature 'sig' # Signature directory
check 'lib' # Directory name

library 'forwardable' # Standard libraries
end
2 changes: 1 addition & 1 deletion rb/lib/selenium/webdriver/common/logger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def ignore(*ids)
#
# @param [Array, Symbol] ids
#
def allow(ids)
def allow(*ids)
@allowed += Array(ids).flatten
end

Expand Down
25 changes: 25 additions & 0 deletions rb/sig/lib/selenium/webdriver/common/log_entry.rbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
module Selenium
module WebDriver
class LogEntry
@level: String

@timestamp: Integer

@message: String

attr_reader level: String

attr_reader timestamp: Integer

attr_reader message: String

def initialize: (String level, Integer timestamp, String message) -> void

def as_json: (*untyped?) -> Hash[String, Integer | String]

def to_s: () -> String

def time: () -> Time
end
end
end
30 changes: 18 additions & 12 deletions rb/sig/lib/selenium/webdriver/common/logger.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,39 @@ module Selenium
class Logger
extend Forwardable

def initialize: (?::String progname, ?default_level: Symbol? default_level, ?ignored: bool? ignored, ?allowed: bool? allowed) -> void
@allowed: Array[Symbol]
@first_warning: bool

def level=: (Symbol level) -> untyped
@ignored: Array[Symbol]
@logger: ::Logger

def output=: (String io) -> IO
def initialize: (?::String progname, ?default_level: Symbol? default_level, ?ignored: Array[Symbol]? ignored, ?allowed: Array[Symbol]? allowed) -> void

def level=: (Symbol level) -> Symbol

def output=: (String io) -> ::Logger

def io: () -> IO

def ignore: (*Symbol ids) -> untyped
def ignore: (*Symbol ids) -> Array[Symbol]

def allow: (*Symbol ids) -> untyped
def allow: (*Symbol ids) -> Array[Symbol]

def debug: (String message, ?id: Symbol | Array[Symbol] id) { () -> untyped } -> untyped
def debug: (String message, ?id: Symbol | Array[Symbol] id) ?{ () -> void } -> void

def info: (String message, ?id: Symbol | Array[Symbol] id) { () -> untyped } -> untyped
def info: (String message, ?id: Symbol | Array[Symbol] id) ?{ () -> void } -> void

def error: (String message, ?id: Symbol | Array[Symbol] id) { () -> untyped } -> untyped
def error: (String message, ?id: Symbol | Array[Symbol] id) { () -> void } -> void

def warn: (String message, ?id: Symbol | Array[Symbol] id) { () -> untyped } -> untyped
def warn: (String message, ?id: Symbol | Array[Symbol] id) { () -> void } -> void

def deprecate: (String old, ?String? new, ?id: Symbol | Array[Symbol] id, ?reference: ::String reference) { () -> untyped } -> (nil | untyped)
def deprecate: (String old, ?String? new, ?id: Symbol | Array[Symbol] id, ?reference: ::String reference) { () -> void } -> (void)

private

def create_logger: (String name, level: Symbol level) -> untyped
def create_logger: (String name, level: Symbol level) -> ::Logger

def discard_or_log: (Symbol level, String message, Symbol | Array[Symbol] id) { () -> untyped } -> (nil | untyped)
def discard_or_log: (Symbol level, String message, (::Symbol | ::Array[::Symbol]) | [(::Symbol | ::Array[::Symbol])] id) ?{ () -> void } -> (void)
end
end
end

0 comments on commit 36585d1

Please sign in to comment.