> For the complete documentation index, see [llms.txt](https://triton.pharos.ai/pharos-triton/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://triton.pharos.ai/pharos-triton/triton-best-practices/core-principles.md).

# Core Principles

## Goals & Principles

Effective logging with Triton is built on seven core principles that ensure your logs are consistent, useful, and maintainable:

### 1. **Consistency First**

Every log must carry consistent metadata (Category, Type, Area, Level, TransactionId, Operation/Function, Context). This consistency enables powerful filtering, grouping, and analysis across your entire org.

### 2. **Context-Rich**

Prefer builder + template patterns to capture **who/what/where/when/how** (user, related objects, stack/operation, runtime info, duration). Rich context transforms logs from simple messages into powerful debugging tools.

### 3. **Standards-Driven**

Enforce a **Type/Area taxonomy** org-wide. Don't invent ad-hoc strings. Use the established enums and extend them systematically when needed.

### 4. **Right Level, Right Volume**

Use **Level** appropriately; rely on Triton's dynamic filtering (e.g., via metadata) rather than hard-coding if/else conditions. This allows you to tune verbosity by environment without code changes.

### 5. **Safe & Useful**

Never log secrets/PII. Do log correlation identifiers, IDs, and performance signals. Balance security with debugging value.

### 6. **Transaction-Aware**

Start/Resume/Stop transactions across LWC → Apex → Flow boundaries to correlate events end-to-end. This creates complete execution traces across technology boundaries.

### 7. **Buffer Smartly**

Use Triton buffering + auto-flush for performance; flush at boundaries and on errors. This optimizes performance while ensuring critical logs are never lost.

## Why These Principles Matter

These principles work together to create a logging system that:

* **Scales with your org**: Consistent patterns work across teams and technologies
* **Provides actionable insights**: Rich context enables effective debugging and monitoring
* **Maintains performance**: Smart buffering and filtering keep overhead minimal
* **Enables correlation**: Transaction awareness creates end-to-end visibility
* **Supports compliance**: Proper handling of sensitive data and audit requirements

## Implementation Philosophy

The principles guide implementation decisions:

* **Templates over convenience methods**: Templates ensure consistency and reduce drift
* **Context over brevity**: More context is better than less, within reason
* **Standards over flexibility**: Consistent taxonomy enables powerful analysis
* **Performance awareness**: Buffer appropriately and flush strategically
* **Security first**: Never compromise security for debugging convenience

By following these principles, you'll create a logging system that grows with your org and provides lasting value for debugging, monitoring, and compliance.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://triton.pharos.ai/pharos-triton/triton-best-practices/core-principles.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
