native.json 2.4 KB

1234567
  1. {
  2. "support_level": "production",
  3. "type": "language",
  4. "name": "Native (C/C++)",
  5. "doc_link": "https://docs.sentry.io/error-reporting/quickstart/?platform=native",
  6. "body": "<p>Install the SDK by downloading the <a href=\"https://github.com/getsentry/sentry-native/releases\">latest\nrelease</a>. Next, follow the\ninstructions in the <a href=\"https://docs.sentry.io/platforms/native/\"><em>Native SDK Documentation</em></a> to build and link the SDK\nlibrary.</p>\n\n \n\n\n\n\n <p>Import and initialize the Sentry SDK early in your application setup:</p>\n\n<pre class=\"highlight\"><code><span class=\"cp\">#include &lt;sentry.h&gt;\n</span>\n<span class=\"kt\">int</span> <span class=\"nf\">main</span><span class=\"p\">(</span><span class=\"kt\">void</span><span class=\"p\">)</span> <span class=\"p\">{</span>\n <span class=\"n\">sentry_options_t</span> <span class=\"o\">*</span><span class=\"n\">options</span> <span class=\"o\">=</span> <span class=\"n\">sentry_options_new</span><span class=\"p\">();</span>\n <span class=\"n\">sentry_options_set_dsn</span><span class=\"p\">(</span><span class=\"n\">options</span><span class=\"p\">,</span> <span class=\"s\">\"___PUBLIC_DSN___\"</span><span class=\"p\">);</span>\n <span class=\"n\">sentry_init</span><span class=\"p\">(</span><span class=\"n\">options</span><span class=\"p\">);</span>\n\n <span class=\"cm\">/* ... */</span>\n\n <span class=\"c1\">// make sure everything flushes</span>\n <span class=\"n\">sentry_shutdown</span><span class=\"p\">();</span>\n<span class=\"p\">}</span>\n</code></pre>\n\n<p>Alternatively, the DSN can be passed as <code class=\"highlighter-rouge\">SENTRY_DSN</code> environment variable during\nruntime. This can be especially useful for server applications.</p>\n\n \n\n\n\n <p>The quickest way to verify Sentry in your Native application is by capturing a message:</p>\n\n<pre class=\"highlight\"><code><span class=\"n\">sentry_capture_event</span><span class=\"p\">(</span><span class=\"n\">sentry_value_new_message_event</span><span class=\"p\">(</span>\n <span class=\"cm\">/* level */</span> <span class=\"n\">SENTRY_LEVEL_INFO</span><span class=\"p\">,</span>\n <span class=\"cm\">/* logger */</span> <span class=\"s\">\"custom\"</span><span class=\"p\">,</span>\n <span class=\"cm\">/* message */</span> <span class=\"s\">\"It works!\"</span><span class=\"p\">,</span>\n<span class=\"p\">));</span>\n</code></pre>"
  7. }