All Products
Search
Document Center

Simple Log Service:C Producer SDK

Last Updated:Nov 17, 2023

This topic describes how to use C Producer SDK.

Simple Log Service C Producer is a log collection agent that is written only in the C programming language. C Producer requires only simple environment dependencies and consumes low resources. You can use C Producer to collect logs from embedded and smart devices.

Features

  • Asynchronous writing

    • Logs are asynchronously written, and agent threads are not blocked.

  • Log aggregation and compression

    • Logs can be aggregated based on the timeout period, log quantity, and log size and then uploaded.

    • Logs can be compressed by using the LZ4 algorithm and then uploaded.

  • Contextual query

    • Logs that are generated by a device are in the same context. You can view the logs that are generated before and after a specified log in Simple Log Service.

  • Concurrent sending

    • You can configure a thread pool to concurrently send logs.

  • Caching

    • You can specify an upper limit for caching. If the size of cached logs reaches the upper limit, logs can no longer be written to the cache.

  • Custom identifier

    • By default, logs are uploaded with IP addresses.

    • You can specify custom tags and topics.

Benefits

  • C Producer supports high concurrent write operations. You can configure a thread pool to write hundreds of thousands of logs per second to Simple Log Service. For more information, see Performance test.

  • C Producer consumes low resources: Only 30% of CPU resources is consumed to write 200, 000 logs per second. The resources are not affected when 100 logs are generated per second on low-performance hardware such as Raspberry Pi. For more information, see Performance test.

  • C Producer does not store logs. After logs are generated, the logs are directly sent to Simple Log Service.

  • Logic isolation between computing and I/O: Logs are written in an asynchronous manner without blocking worker threads.

  • Reliable exit: When a program exits, it calls an operation to store logs. When the program restarts, the logs are sent to Simple Log Service to ensure data reliability. For more information, see Solution to reliable program exit.

Version selection

You can select a C Producer version based on your device type and usage scenarios.

Version

Status

Benefit

Recommended scenario

master

Available

The master version is the original lite version. Compared with the v1 (1.0f) version, the master version requires simpler dependencies, consumes lower resources, and provides higher performance. The master version provides the best producer performance among all available versions. We recommend that you use the master version.

Linux servers and embedded Linux devices.

live

Available

The live version provides the same features as the master version. The live version supports the most platforms during compilation, including Windows, macOS, Android, and iOS platforms.

Scenarios in which the master version is not supported.

bricks

Available

The bricks version is ultra-compact. This version consumes extremely low binary and memory resources but provides features that have limited performance. We recommend that you use the bricks version in scenarios when you do not have sufficient resources.

Scenarios in which resource usage is less than 10 KB, such as Real-time operating system (RTOS)-involved scenarios.

persistent

Available

Compared with the master version, the persistent version adds the local cache feature. This feature is used in the native implementation for the mobile versions of Android and iOS. If you enable the local cache feature, you can use only a single thread to send data. We recommend that you do not use this version when you send data to Simple Log Service.

We recommend that you use official SDKs for Android and iOS.

Download and installation

For more information about how to download source code and install C Producer, see the GitHub documentation.