<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 18.0.0 -",
    "visionOS: 2.0.0 -",
    "watchOS: 11.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Accelerate",
  "identifier" : "/documentation/Accelerate/BNNSGraphContextSetMessageLogCallback(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Accelerate"
    ],
    "preciseIdentifier" : "c:@F@BNNSGraphContextSetMessageLogCallback"
  },
  "title" : "BNNSGraphContextSetMessageLogCallback(_:_:_:)"
}
-->

# BNNSGraphContextSetMessageLogCallback(_:_:_:)

Specifies a customized callback function that reports execution-time messages.

```
func BNNSGraphContextSetMessageLogCallback(_ context: bnns_graph_context_t, _ log_callback_fn: bnns_graph_execute_message_fn_t, _ additional_logging_arguments: UnsafeMutablePointer<bnns_user_message_data_t>?) -> Int32
```

## Parameters

`context`

The graph context.

`log_callback_fn`

The message-logging callback function.

`additional_logging_arguments`

Additional data for the message logging functions that BNNS passes unaltered to the callback function.

## Return Value

`0` on success, nonzero on failure.

## Discussion

The following code adds a custom context execute-message callback function that prints messages to the console:

```swift
BNNSGraphContextSetMessageLogCallback(context, messageLogCallback, nil)

func messageLogCallback(msg_level: BNNSGraphMessageLevel,
                        error_msg: UnsafePointer<CChar>,
                        op_info: UnsafePointer<CChar>?,
                        additional_logging_arguments: UnsafeMutablePointer<user_message_data_t>?) {

    print(NSString(cString: error_msg, encoding: NSUTF8StringEncoding) ?? "")
    if let op_info = op_info {
        print(NSString(cString: op_info, encoding: NSUTF8StringEncoding) ?? "")
    }
}
```

---

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)