<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/OSSignposter/emitEvent(_:id:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "s:2os12OSSignposterV9emitEvent_2id_ys12StaticStringV_AA12OSSignpostIDVAA12OSLogMessageVtF"
  },
  "title" : "emitEvent(_:id:_:)"
}
-->

# emitEvent(_:id:_:)

Marks a point of interest in time and attaches the specified message.

```
func emitEvent(_ name: StaticString, id: OSSignpostID = .exclusive, _ message: SignpostMetadata)
```

## Parameters

`name`

The event’s name.

`id`

The event’s identifier. The default value is [`exclusive`](/documentation/os/OSSignpostID/exclusive).

`message`

The interpolated string that the signposter attaches to the event. Each of the message’s interpolations can specify individual formatting and privacy options. For more information, see [Message Argument Formatters](/documentation/os/message-argument-formatters).

## Discussion

> Important:
> Don’t create an instance of ``doc://com.apple.os/documentation/os/SignpostMetadata``. Instead, provide an interpolated string as the `message` parameter and the system converts it automatically.

You can use the [`makeSignpostID()`](/documentation/os/OSSignposter/makeSignpostID()) and [`makeSignpostID(from:)`](/documentation/os/OSSignposter/makeSignpostID(from:)) methods to generate an identifier for the event, as the following example shows:

```swift
let accountNumber = "12345678"

// Create a signposter using the default subsystem.
let signposter = OSSignposter()
        
// Generate a signpost ID to associate with the event.
let signpostID = signposter.makeSignpostID()
        
// Emit a named event using the signpost ID and attach a message
// that securely interpolates sensitive data.
signposter.emitEvent("New Account Created", id: signpostID,
    "Account: \(accountNumber, privacy: .sensitive(mask: .hash))")
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)