> For the complete documentation index, see [llms.txt](https://dev.teaproject.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dev.teaproject.org/020_tutorial/070_gas_fee_payment/071_query_logs.md).

# Query logs

In this `gas` branch, there's only one major change and it's in the **sample-actor** project. The **sample-txn-executor** has no change because it has nothing to do with gas fee logs. The sample-front-end added a new UI but mainly it's just typical VUE web UI code changes, so there's no need to explain it in our tutorial. So let's only focus on the **sample-actor** project.

We'll need to add a new query to get the list of logs and a txn to set the allowance. You can find them in the `dfn.rs` file:

```
pub fn name_list() -> Vec<&'static str> {
	vec![
		"say-hello",
		"faucet",
		"create_task",
		"query_task_list",
		"delete_task",
		"verify_task",
		"take_task",
		"complete_task",
		"init_db",
		"init_token",
		"queryOpLogs",//this is the newly added function
		"setAllowance",
	]
}
```

These are called "queryOpLogs" and 'setAllownace' which you can see at the end of the file. The txn to `setAllowance` is related to the fact that each TApp has an allowance associated with it. The TApp will only be able to spend user funds up to the amount set as the allowance.

In **api.rs** you can find the `async fn query_op_logs` function. The major logic is to call the `get_statements_async` function.

```
	let (statements, read_to_end) = get_statements_async(
		acct,
		date,
		IntelliSendMode::RemoteOnly,
	)
	.await?;
```

then convert the rows to human readable format:

```
	let mut rows: Vec<JsonStatement> = Vec::new();
	for item in statements {
		let s = item.0;
		let tmp = JsonStatement {
			account: format!("{:?}", s.statement.account),
			gross_amount: s.statement.gross_amount.to_string(),
			statement_type: s.statement.statement_type.to_string(),
			token_id: s.statement.token_id.to_hex(),
			state_type: s.state_type.to_string(),
			memo: item.2,
			time: item.1,
		};
		rows.push(tmp);
	}
```

In our runtime, we store records in the log based on date. So we'll query the backend on which dates to query.

```
	let date: Option<SimpleDate> = req
		.year
		.as_ref()
		.map(|year| SimpleDate::new(*year, req.month.unwrap_or(1_u32), req.day.unwrap_or(1_u32)));
```

Once we've received the json response, the calback function formats them to a UI-friendly format. After that, `help::cache_json_with_uuid(&uuid, x).await?;` caches it to local memory and waits for the front end to check this result at a later time.

The code above shows a typical example of how to convert the data from the backend to the web UI friendly format. In this tutorial we cover it for TApp development but it's the same formatting that's commonly used everywhere.


---

# 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://dev.teaproject.org/020_tutorial/070_gas_fee_payment/071_query_logs.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.
