Hide navigation sidebar
Hide table of contents sidebar
Back to top
Toggle table of contents sidebar

# Log

Provides access to log entries.

- Types

- Commands

- Events

## Types

Generally, you do not need to instantiate CDP types yourself. Instead, the API creates objects for you as return values from commands, and then you can use those objects as arguments to other commands.

class LogEntry(source, level, text, timestamp, category=None, url=None, line_number=None, stack_trace=None, network_request_id=None, worker_id=None, args=None)

  Log entry.

  source: `str`

    Log entry source.

  level: `str`

    Log entry severity.

  text: `str`

    Logged text.

  timestamp: `Timestamp`

    Timestamp when this entry was added.

  category: `Optional`[`str`] = None
  url: `Optional`[`str`] = None

    URL of the resource if known.

  line_number: `Optional`[`int`] = None

    Line number in the resource.

  stack_trace: `Optional`[`StackTrace`] = None

    JavaScript stack trace.

  network_request_id: `Optional`[`RequestId`] = None

    Identifier of the network request associated with this entry.

  worker_id: `Optional`[`str`] = None

    Identifier of the worker associated with this entry.

  args: `Optional`[`List`[`RemoteObject`]] = None

    Call arguments.

class ViolationSetting(name, threshold)

  Violation configuration setting.

  name: `str`

    Violation type.

  threshold: `float`

    Time threshold to trigger upon.

## Commands

Each command is a generator function. The return type `Generator[x, y, z]` indicates that the generator yields arguments of type `x`, it must be resumed with an argument of type `y`, and it returns type `z`. In this library, types `x` and `y` are the same for all commands, and `z` is the return type you should pay attention to. For more information, see Getting Started: Commands.

clear()

  Clears the log.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

disable()

  Disables log domain, prevents further log entries from being reported to the client.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

enable()

  Enables log domain, sends the entries collected so far to the client by means of the `entryAdded` notification.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

start_violations_report(config)

  start violation reporting.

  Parameters:

    config (`List`[`ViolationSetting`]) – Configuration for violations.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

stop_violations_report()

  Stop violation reporting.

  Return type:

    `Generator`[`Dict`[`str`, `Any`], `Dict`[`str`, `Any`], `None`]

## Events

Generally, you do not need to instantiate CDP events yourself. Instead, the API creates events for you and then you use the event’s attributes.

class EntryAdded(entry)

  Issued when new message was logged.

  entry: `LogEntry`

    The entry.