Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DLT Upstream for minor release #515

Merged
merged 26 commits into from
Aug 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
1425dc6
android: improve sepolicy android
tdinhcong Oct 12, 2021
743a10f
android: Remove duplicated contexts
ssugiura Oct 18, 2021
a0c8183
doc: Use DLT in library
ssugiura Oct 26, 2021
b6f6c34
common: Fix dlt.conf parse
thanhbnq Nov 29, 2021
a7479b2
tests: Use env var in gateway gtest
ssugiura Oct 26, 2021
8ad2c07
daemon: Print errno on failure
ssugiura Jan 28, 2022
7063b4e
daemon: Remove unnecessary semaphore
thanhbnq Apr 20, 2022
29f6d59
android: Add jsoncpp lib for dlt-logd-converter
Jun 1, 2022
ab5868c
android: Update md file for dlt-logd-converter
Jun 1, 2022
44ead0a
android: dlt-logd-converter enhancement for Android tags
Jun 1, 2022
d2d13e4
dlt-daemon: Handle partial message parsing in receiver buffer
Suprathik-N Jul 14, 2022
b112bea
android: Fix memory leak
Jul 14, 2022
2ecc745
android: Remove redundant code
Jul 19, 2022
25a7c64
qnx: Eliminate project specific information
Jul 19, 2022
3177495
android: Add some binaries in Android
Le-Tin Jul 20, 2022
04b3b18
dlt-control-common: Remove pthread_cancel
Le-Tin Jul 1, 2022
2d90469
qnx: timer pipes could be invalid
thanhbnq Aug 2, 2022
5c049ea
daemon: overflow message should be sent one
thanhbnq Aug 16, 2022
0ff69ee
unittest: Add conf files and json file for unit test
Aug 11, 2022
10fd4c7
common: Modify dlt_common unit test
Aug 18, 2022
d7ea950
unittest: Unit test for dlt-logd-converter
Aug 11, 2022
91503cd
android: Replace macro and use flag directly
Aug 29, 2022
5058aac
android: Avoid SIGSEGV in dlt-logd-converter
Nov 21, 2022
0d04fd9
unittest: Trigger abnormal case for get conf file data in dlt-logd-co…
Nov 21, 2022
ce5f8ad
unittest: Correct macro value in DLT logd converter unit test
Feb 23, 2023
053358f
system: Bring in vrte changes to zero initialize configuration variables
Mar 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 104 additions & 1 deletion Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,111 @@ cc_binary {
shared_libs: [
"libdlt",
"liblog",
"libjsoncpp",
],
include_dirs: [
"system/logging/liblog/include",
"external/jsoncpp/include",
],
}

// vim: ft=python
cc_binary {

name: "dlt-control",
defaults: ["dlt_defaults"],

srcs: [
"src/console/dlt-control-common.c",
"src/console/dlt-control.c",
],

shared_libs: [
"libc",
"libdlt",
],
}

cc_binary {

name: "dlt-convert",
defaults: ["dlt_defaults"],

srcs: [
"src/console/dlt-convert.c",
],

shared_libs: [
"libc",
"libdlt",
],
}

cc_binary {

name: "dlt-test-non-verbose",
defaults: ["dlt_defaults"],

srcs: [
"src/tests/dlt-test-non-verbose.c",
],

shared_libs: [
"libc",
"libdlt",
],
}

cc_binary {

name: "dlt-test-logstorage",
defaults: ["dlt_defaults"],

srcs: [
"src/tests/dlt-test-logstorage.c",
],

shared_libs: [
"libc",
"libdlt",
],
}

cc_binary {

name: "dlt-test-multi-process",
defaults: ["dlt_defaults"],

srcs: [
"src/tests/dlt-test-multi-process.c",
],

shared_libs: [
"libc",
"libdlt",
],
}

cc_binary {

name: "dlt-logstorage-ctrl",
defaults: ["dlt_defaults"],

local_include_dirs: [
"systemd/3rdparty/",
"src/console",
"src/console/logstorage",
],

srcs: [
"src/console/dlt-control-common.c",
"src/console/logstorage/dlt-logstorage-common.c",
"src/console/logstorage/dlt-logstorage-ctrl.c",
],

shared_libs: [
"libc",
"libdlt",
],
}

// vim: ft=python
93 changes: 93 additions & 0 deletions doc/dlt-logd-converter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# dlt-logd-converter

Android specific logging features of dlt are managed by the ```dlt-logd-converter``` process.
It currently contains the message forwarder from logd buffer to DLT.

The application listens to the system logs on Android (logd) and sends them to
DLT. The prerequisite is that dlt-daemon is already started and running.
dlt-logd-converter loads by default the configuration file ```/vendor/etc/dlt-logd-converter.conf```.

To change the log level, use application ID and context ID set in configuration
file. ```DLT_INITIAL_LOG_LEVEL``` can be set on startup phase, or control
message can be sent from DLT client (e.g. dlt-control, DLT Viewer) at runtime.
Refer to [dlt_for_developers.md](dlt_for_developers.md) for more detail.


## Usage

```bash
dlt-logd-converter [-h] [-c FILENAME]
```

-h

: Display a short help text.

-c

: Load an alternative configuration file. By default the configuration file
*/vendor/etc/dlt-logd-converter.conf* is loaded.


Non zero is returned in case of failure.


## Configuration

By default, the configuration is loaded from */vendor/etc/dlt-logd-converter.conf*. It
contains a few basic options:

- *ApplicationID*: this Android system log forwarder will have this applicationn ID
and appear on DLT client. Default value is **LOGD**.

- *ContextID*: the context ID of the above application to appear on DLT client.
Default value is **LOGF**.

- *AndroidLogdJSONpath*: the JSON file for MAIN buffer app logs should be looked up at
a defined path to use the context ID extension feature. If not found, the primitive context ID
**MAIN** is applied for all. Default path is */vendor/etc/dlt-logdctxt.json*.

- *AndroidLogdContextID*: If the JSON path is found, but applications are not listed in JSON file,
default context ID is **OTHE**.

### Log level mapping

As the severity levels on Android logs are different from DLT Log Level, the below table shows how they're converted from the former to the latter.


| Android System Log Level | DLT Log Level |
|--------------------------|--------------------|
| ANDROID\_LOG\_DEFAULT | DLT\_LOG\_DEFAULT |
| ANDROID\_LOG\_UNKNOWN | DLT\_LOG\_DEFAULT |
| ANDROID\_LOG\_SILENT | DLT\_LOG\_OFF |
| ANDROID\_LOG\_FATAL | DLT\_LOG\_FATAL |
| ANDROID\_LOG\_ERROR | DLT\_LOG\_ERROR |
| ANDROID\_LOG\_WARN | DLT\_LOG\_WARN |
| ANDROID\_LOG\_INFO | DLT\_LOG\_INFO |
| ANDROID\_LOG\_DEBUG | DLT\_LOG\_DEBUG |
| ANDROID\_LOG\_VERBOSE | DLT\_LOG\_VERBOSE |


### Context Mapping

The json file dlt-logdctxt.json can be used to map android tags to dlt-contexts.

#### Example

Here is an example that sets a mapping from the tag "usbcore" to the DLT context "USBC",
and the tag "dummy_hcd.0" to the DLT Context "DUMM".
The description field is in the registration with libdlt.

```python
{
"USBC": {
"tag": "usbcore",
"description": ""
},
"DUMM": {
"tag": "dummy_hcd.0",
"description": ""
}
}
```
For the tags that are not listed, the mapping context ID should all be "OTHE".
34 changes: 34 additions & 0 deletions doc/dlt_for_developers.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Table of Contents
5. [DLT API Usage](#DLT-API-Usage)
6. [DLT injection messages](#DLT-Injection-Messages)
7. [Log level changed callback](#Log-level-changed-callback)
8. [Disable injection messages](#Disable-injection-messages)
9. [Use DLT in library](#Use-DLT-in-library)

## DLT Example Application

Expand Down Expand Up @@ -989,6 +991,7 @@ context changed. The usage is similar to DLT\_REGISTER\_INJECTION\_CALLBACK.
```
DLT_REGISTER_LOG_LEVEL_CHANGED_CALLBACK(CONTEXT, CALLBACK)
```

## Disable injection messages

An environment variable named `DLT_DISABLE_INJECTION_MSG_AT_USER` could be used in case
Expand All @@ -1005,3 +1008,34 @@ To clear:
```
unset DLT_DISABLE_INJECTION_MSG_AT_USER
```

## Use DLT in library

There are cases where a library wants to use DLT interface to output its log message.
In such case, applications and contexts can be registered using following way.

### Application registration

The library can check if an application is already registered or not by
`DLT_GET_APPID()` API. If returned application ID is not NULL, it can be considered
that application was already registered previously. If it's NULL, then application
can be registered.

```Example
// Check if an application is already registered in this process
char appid[DLT_ID_SIZE];
DLT_GET_APPID(&appid);
if (appid[0] != '\0')
{
printf("Application is already registered with AppID=[%s]\n", appid);
}
else
{
DLT_REGISTER_APP("APP", "Application for library xxx");
}
```

### Context registration

The same context ID can be used among different applications, so context can be
registered as usual.
Loading