Read-only git subtree of liblog/ from aosp/platform/system/core/

Clone this repo:
  1. 9cca708 remove copybara initialization artifacts by Treehugger Robot · 4 years, 7 months ago factory-14162.B factory-14778.B factory-ambassador-14265.B factory-asurada-13929.B factory-brox-16086.B factory-brya-14517.B factory-brya-14909.124.B factory-brya-15231.B factory-brya-15684.B factory-cherry-14455.B factory-corsola-15196.B factory-corsola-15197.B factory-dedede-13683.B factory-firmware-ti50-guc-14778.B factory-foobar-15000.B factory-geralt-15840.B factory-guybrush-14600.B factory-guybrush-14908.B factory-keeby-14162.B factory-kukui-14374.B factory-nissa-15199.B factory-nissa-16077.B factory-puff-13813.B factory-rex-15708.B factory-skyrim-15384.B factory-strongbad-13963.B factory-test-13517.B factory-test-13683.B factory-trogdor-15210.B factory-volteer-13600.B factory-zork-13700.B firmware-14505.782.B firmware-14947.B firmware-R126-15885.B firmware-R127-15916.B firmware-R128-15963.B firmware-R129-16001.B firmware-R130-16032.B firmware-R131-16062.B firmware-android-15949.B firmware-android-brya-14505.782.B firmware-android-corsola-15194.225.B firmware-android-dedede-13606.653.B firmware-android-dedede-13606.655.B firmware-android-geralt-15842.88.B firmware-android-nissa-15217.630.B firmware-asurada-13885.B firmware-brox-16080.B firmware-brya-14505.534.B firmware-brya-14505.71.B firmware-brya-14505.B firmware-chameleon-14280.B firmware-chameleon-14947.B firmware-cherry-14454.B firmware-corsola-15194.92.B firmware-corsola-15194.B firmware-cr50-efi-15611.28.B firmware-cr50-mp-15611.B firmware-cr50-prepvt-15608.B firmware-cr50-stab-14294.B firmware-cr50-stab-mp-14300.B firmware-dedede-13606.456.B firmware-dedede-13606.458.B firmware-dedede-13606.516.B firmware-dedede-13606.533.B firmware-dedede-13606.674.B firmware-dedede-13606.B firmware-duplo-15151.B firmware-ec-R131-16063.2.B firmware-ec-R132-16093.3.B firmware-firmware-android-brya-recipe-test-14505.782.B firmware-geralt-15842.B firmware-guybrush-14500.B firmware-hps-15892.B firmware-keeby-14119.B firmware-nissa-15217.126.B firmware-nissa-15217.253.B firmware-nissa-15217.279.B firmware-nissa-15217.45.B firmware-nissa-15217.694.B firmware-nissa-15217.B firmware-quiche-13883.B firmware-rex-15709.B firmware-skyrim-15369.B firmware-skyrim-15390.B firmware-ti50-mp-15224.B firmware-ti50-mp-15980.B firmware-ti50-prepvt-15086.B firmware-ti50-prepvt-15974.B firmware-trogdor-13577.B firmware-volteer-13521.B firmware-volteer-13672.130.B firmware-volteer-13672.148.B firmware-volteer-13672.156.B firmware-volteer-13672.39.B firmware-volteer-13672.47.B firmware-volteer-13672.81.B firmware-volteer-13672.B master release-R100-14526.B release-R101-14588.B release-R102-14695.B release-R103-14816.B release-R104-14909.B release-R105-14989.B release-R106-15054.B release-R107-15117.B release-R108-15183.B release-R109-15236.B release-R110-15278.B release-R111-15329.B release-R112-15359.B release-R113-15393.B release-R114-15437.B release-R115-15474.B release-R116-15509.B release-R117-15572.B release-R118-15604.B release-R119-15633.B release-R120-15662.B release-R121-15699.B release-R122-15753.B release-R123-15786.B release-R124-15823.B release-R125-15853.B release-R126-15886.B release-R127-15917.B release-R128-15964.B release-R129-16002.B release-R130-16033.B release-R131-16063.B release-R132-16093.B release-R87-13505.B release-R88-13597.B release-R89-13729.B release-R90-13816.B release-R91-13904.B release-R92-13982.B release-R93-14092.B release-R94-14150.49.B release-R94-14150.B release-R96-14268.B release-R97-14324.B release-R98-14388.B release-R99-14469.B stabilize-13482.B stabilize-13505.1.B stabilize-13505.100.B stabilize-13505.111.B stabilize-13505.63.B stabilize-13505.65.B stabilize-13505.73.B stabilize-13505.85.B stabilize-13525.B stabilize-13532.B stabilize-13591.B stabilize-13597.103.B stabilize-13597.105.B stabilize-13597.66.B stabilize-13597.67.B stabilize-13597.68.B stabilize-13597.69.B stabilize-13597.70.B stabilize-13597.71.B stabilize-13597.84.B stabilize-13597.85.B stabilize-13597.90.B stabilize-13597.94.B stabilize-13597.95.B stabilize-13597.97.B stabilize-13605.B stabilize-13654.B stabilize-13729.16.B stabilize-13729.45.B stabilize-13729.49.B stabilize-13729.56.B stabilize-13729.57.B stabilize-13729.72.B stabilize-13768.B stabilize-13799.B stabilize-13816.40.B stabilize-13816.51.B stabilize-13816.53.B stabilize-13816.55.B stabilize-13816.63.B stabilize-13816.64.B stabilize-13816.80.B stabilize-13816.82.B stabilize-13821.B stabilize-13836.B stabilize-13851.B stabilize-13856.B stabilize-13895.B stabilize-13904.34.B stabilize-13904.41.B stabilize-13904.42.B stabilize-13904.43.B stabilize-13904.44.B stabilize-13904.47.B stabilize-13904.48.B stabilize-13904.49.B stabilize-13904.55.B stabilize-13904.58.B stabilize-13904.59.B stabilize-13904.62.B stabilize-13904.66.B stabilize-13904.67.B stabilize-13935.B stabilize-13942.B stabilize-13970.B stabilize-13971.B stabilize-13974.B stabilize-13982.51.B stabilize-13982.60.B stabilize-13982.69.B stabilize-13982.70.B stabilize-13982.82.B stabilize-13982.88.B stabilize-13983.B stabilize-14013.B stabilize-14023.B stabilize-14026.B stabilize-14029.B stabilize-14031.B stabilize-14057.B stabilize-14092.57.B stabilize-14092.66.B stabilize-14093.B stabilize-14094.B stabilize-14106.B stabilize-14149.B stabilize-14150.2755.B stabilize-14150.376.B stabilize-14150.43.B stabilize-14150.64.B stabilize-14150.734.B stabilize-14150.74.B stabilize-14150.881.B stabilize-14150.882.B stabilize-14150.883.B stabilize-14151.B stabilize-14163.B stabilize-14178.B stabilize-14179.B stabilize-14189.B stabilize-14217.B stabilize-14235.B stabilize-14238.B stabilize-14249.B stabilize-14267.B stabilize-14268.51.B stabilize-14268.52.B stabilize-14268.67.B stabilize-14285.B stabilize-14312.B stabilize-14321.B stabilize-14324.13.B stabilize-14324.41.B stabilize-14324.62.B stabilize-14324.72.B stabilize-14333.B stabilize-14336.B stabilize-14345.B stabilize-14385.B stabilize-14388.52.B stabilize-14388.61.B stabilize-14388.62.B stabilize-14395.B stabilize-14396.B stabilize-14411.B stabilize-14438.B stabilize-14442.B stabilize-14469.41.B stabilize-14469.58.B stabilize-14469.8.B stabilize-14469.9.B stabilize-14477.B stabilize-14496.B stabilize-14498.B stabilize-14526.57.B stabilize-14526.67.B stabilize-14526.73.B stabilize-14526.84.B stabilize-14526.89.B stabilize-14528.B stabilize-14532.B stabilize-14536.B stabilize-14588.123.B stabilize-14588.14.B stabilize-14588.98.B stabilize-14589.B stabilize-14616.B stabilize-14633.B stabilize-14682.B stabilize-14695.107.B stabilize-14695.85.B stabilize-14771.B stabilize-14790.B stabilize-14803.B stabilize-14816.131.B stabilize-14816.136.B stabilize-14816.138.B stabilize-14816.82.B stabilize-14816.84.B stabilize-14839.B stabilize-14909.100.B stabilize-14918.B stabilize-14964.B stabilize-14989.107.B stabilize-14989.85.B stabilize-14998.B stabilize-15032.B stabilize-15033.B stabilize-15054.115.B stabilize-15054.26.B stabilize-15054.98.B stabilize-15072.B stabilize-15083.B stabilize-15086.B stabilize-15117.111.B stabilize-15117.48.B stabilize-15117.86.B stabilize-15120.B stabilize-15122.B stabilize-15129.B stabilize-15167.B stabilize-15174.B stabilize-15183.14.B stabilize-15183.69.B stabilize-15183.82.B stabilize-15185.7.B stabilize-15185.B stabilize-15207.B stabilize-15208.B stabilize-15236.66.B stabilize-15245.B stabilize-15251.B stabilize-15278.64.B stabilize-15300.B stabilize-15301.B stabilize-15317.B stabilize-15329.44.B stabilize-15329.59.B stabilize-15335.B stabilize-15359.45.B stabilize-15359.50.B stabilize-15359.58.B stabilize-15361.B stabilize-15364.B stabilize-15381.B stabilize-15393.48.B stabilize-15393.58.B stabilize-15395.B stabilize-15415.B stabilize-15429.B stabilize-15432.B stabilize-15437.42.B stabilize-15437.57.B stabilize-15437.59.B stabilize-15439.B stabilize-15446.B stabilize-15474.38.B stabilize-15474.53.B stabilize-15474.70.B stabilize-15483.B stabilize-15485.B stabilize-15509.37.B stabilize-15509.63.B stabilize-15509.72.B stabilize-15511.B stabilize-15519.B stabilize-15531.B stabilize-15532.B stabilize-15561.B stabilize-15562.B stabilize-15563.B stabilize-15564.B stabilize-15572.16.B stabilize-15572.39.B stabilize-15572.4.B stabilize-15572.50.B stabilize-15572.57.B stabilize-15572.63.B stabilize-15588.B stabilize-15604.16.B stabilize-15604.45.B stabilize-15604.56.B stabilize-15604.57.B stabilize-15610.B stabilize-15633.44.B stabilize-15633.58.B stabilize-15633.69.B stabilize-15642.B stabilize-15654.B stabilize-15662.64.B stabilize-15662.76.B stabilize-15662.78.B stabilize-15662.80.B stabilize-15662.88.B stabilize-15677.B stabilize-15699.58.B stabilize-15699.66.B stabilize-15714.B stabilize-15753.46.B stabilize-15753.55.B stabilize-15756.B stabilize-15786.48.B stabilize-15786.58.B stabilize-15793.B stabilize-15823.40.B stabilize-15828.B stabilize-15855.B stabilize-15857.B stabilize-15886.46.B stabilize-15886.63.B stabilize-15886.66.B stabilize-15888.B stabilize-15905.B stabilize-15917.61.B stabilize-15917.65.B stabilize-15926.B stabilize-15964.20.B stabilize-15964.42.B stabilize-15964.9.B stabilize-16002.44.B stabilize-16002.51.B stabilize-16033.43.B stabilize-16033.58.B stabilize-16055.B stabilize-FLEX-15662.115.B stabilize-LTS-13816.60.B stabilize-RUST-13932.B stabilize-RUST-14057.B stabilize-ambassador-13597.79.B stabilize-ambassador-14268.43.B stabilize-coil-13902.B stabilize-glibc-13901.B stabilize-hps-15890.B stabilize-quickfix-13597.30.B stabilize-quickfix-13729.60.B stabilize-quickfix-13729.73.B stabilize-quickfix-13729.84.B stabilize-quickfix-13816.67.B stabilize-quickfix-13904.98.B stabilize-quickfix-14526.91.B stabilize-quickfix-14695.124.B stabilize-quickfix-14695.187.B stabilize-quickfix-14909.132.B stabilize-quickfix-15183.78.B stabilize-quickfix-15278.72.B stabilize-quickfix-15662.77.B stabilize-quickfix-15786.49.B stabilize-quickfix-15823.44.B stabilize-quickfix-15886.43.B stabilize-rust-13514.B stabilize-rust-13555.B stabilize-rust-13562.B stabilize-rust-13613.B stabilize-rust-13720.B stabilize-rust-13776.B stabilize-rust-13795.B stabilize-rust-13836.B stabilize-rust-14220.B stabilize-rust-14224.B stabilize-rust-14225.B stabilize-starline-16056.B stabilize-starline-16082.B stabilize-starline-16084.B stabilize-starline-16093.2.B stabilize-starline-16095.B stabilize-testbranch-15185.10.B stabilize-voshyr-14637.B stabilize-wristpin-14469.59.B
  2. 3fb7eaa Copybara Service Migration Initialization. by Treehugger Robot · 4 years, 7 months ago
  3. 357ba74 Merge "liblog: remove useless #define" by Treehugger Robot · 4 years, 7 months ago factory-endeavour-13295.B factory-puff-13329.B factory-zork-13427.B firmware-endeavour-13259.B firmware-puff-13324.B release-R85-13310.B release-R86-13421.B stabilize-13310.72.B stabilize-13310.74.B stabilize-13310.83.B stabilize-13310.94.B stabilize-13310.99.B stabilize-13360.B stabilize-13421.102.B stabilize-13421.103.B stabilize-13421.42.B stabilize-13421.53.B stabilize-13421.73.B stabilize-13421.80.B stabilize-13421.89.B stabilize-13421.96.B stabilize-13421.99.B stabilize-lazor-13278.B stabilize-quickfix-13310.73.B stabilize-quickfix-13310.76.B stabilize-quickfix-13310.91.B stabilize-quickfix-13421.100.B stabilize-quickfix-13421.74.B
  4. 464efd7 Merge changes Ib0f33d2f,Ife6c09dd,I55ed5656 by Tom Cherry · 4 years, 7 months ago
  5. 87fe159 Merge changes I5b3ca4f0,I610bed59 by Tom Cherry · 4 years, 7 months ago

Android liblog

Public Functions and Macros

/*
 * Please limit to 24 characters for runtime is loggable,
 * 16 characters for persist is loggable, and logcat pretty
 * alignment with limit of 7 characters.
*/
#define LOG_TAG "yourtag"
#include <log/log.h>

ALOG(android_priority, tag, format, ...)
IF_ALOG(android_priority, tag)
LOG_PRI(priority, tag, format, ...)
LOG_PRI_VA(priority, tag, format, args)
#define LOG_TAG NULL
ALOGV(format, ...)
SLOGV(format, ...)
RLOGV(format, ...)
ALOGV_IF(cond, format, ...)
SLOGV_IF(cond, format, ...)
RLOGV_IF(cond, format, ...)
IF_ALOGC()
ALOGD(format, ...)
SLOGD(format, ...)
RLOGD(format, ...)
ALOGD_IF(cond, format, ...)
SLOGD_IF(cond, format, ...)
RLOGD_IF(cond, format, ...)
IF_ALOGD()
ALOGI(format, ...)
SLOGI(format, ...)
RLOGI(format, ...)
ALOGI_IF(cond, format, ...)
SLOGI_IF(cond, format, ...)
RLOGI_IF(cond, format, ...)
IF_ALOGI()
ALOGW(format, ...)
SLOGW(format, ...)
RLOGW(format, ...)
ALOGW_IF(cond, format, ...)
SLOGW_IF(cond, format, ...)
RLOGW_IF(cond, format, ...)
IF_ALOGW()
ALOGE(format, ...)
SLOGE(format, ...)
RLOGE(format, ...)
ALOGE_IF(cond, format, ...)
SLOGE_IF(cond, format, ...)
RLOGE_IF(cond, format, ...)
IF_ALOGE()
LOG_FATAL(format, ...)
LOG_ALWAYS_FATAL(format, ...)
LOG_FATAL_IF(cond, format, ...)
LOG_ALWAYS_FATAL_IF(cond, format, ...)
ALOG_ASSERT(cond, format, ...)
LOG_EVENT_INT(tag, value)
LOG_EVENT_LONG(tag, value)

log_id_t android_logger_get_id(struct logger *logger)
int android_logger_clear(struct logger *logger)
int android_logger_get_log_size(struct logger *logger)
int android_logger_get_log_readable_size(struct logger *logger)
int android_logger_get_log_version(struct logger *logger)

struct logger_list *android_logger_list_alloc(int mode, unsigned int tail, pid_t pid)
struct logger *android_logger_open(struct logger_list *logger_list, log_id_t id)
struct logger_list *android_logger_list_open(log_id_t id, int mode, unsigned int tail, pid_t pid)
int android_logger_list_read(struct logger_list *logger_list, struct log_msg *log_msg)
void android_logger_list_free(struct logger_list *logger_list)

log_id_t android_name_to_log_id(const char *logName)
const char *android_log_id_to_name(log_id_t log_id)

android_log_context create_android_logger(uint32_t tag)

int android_log_write_list_begin(android_log_context ctx)
int android_log_write_list_end(android_log_context ctx)

int android_log_write_int32(android_log_context ctx, int32_t value)
int android_log_write_int64(android_log_context ctx, int64_t value)
int android_log_write_string8(android_log_context ctx, const char *value)
int android_log_write_string8_len(android_log_context ctx, const char *value, size_t maxlen)
int android_log_write_float32(android_log_context ctx, float value)

int android_log_write_list(android_log_context ctx, log_id_t id = LOG_ID_EVENTS)

android_log_context create_android_log_parser(const char *msg, size_t len)
android_log_list_element android_log_read_next(android_log_context ctx)
android_log_list_element android_log_peek_next(android_log_context ctx)

int android_log_destroy(android_log_context *ctx)

Description

liblog represents an interface to the volatile Android Logging system for NDK (Native) applications and libraries. Interfaces for either writing or reading logs. The log buffers are divided up in Main, System, Radio and Events sub-logs.

The logging interfaces are a series of macros, all of which can be overridden individually in order to control the verbosity of the application or library. [ASR]LOG[VDIWE] calls are used to log to BAsic, System or Radio sub-logs in either the Verbose, Debug, Info, Warning or Error priorities. [ASR]LOG[VDIWE]_IF calls are used to perform thus based on a condition being true. IF_ALOG[VDIWE] calls are true if the current LOG_TAG is enabled at the specified priority. LOG_ALWAYS_FATAL is used to ALOG a message, then kill the process. LOG_FATAL call is a variant of LOG_ALWAYS_FATAL, only enabled in engineering, and not release builds. ALOG_ASSERT is used to ALOG a message if the condition is false; the condition is part of the logged message. LOG_EVENT_(INT|LONG) is used to drop binary content into the Events sub-log.

The log reading interfaces permit opening the logs either singly or multiply, retrieving a log entry at a time in time sorted order, optionally limited to a specific pid and tail of the log(s) and finally a call closing the logs. A single log can be opened with android_logger_list_open(); or multiple logs can be opened with android_logger_list_alloc(), calling in turn the android_logger_open() for each log id. Each entry can be retrieved with android_logger_list_read(). The log(s) can be closed with android_logger_list_free(). ANDROID_LOG_NONBLOCK mode will report when the log reading is done with an EAGAIN error return code, otherwise the android_logger_list_read() call will block for new entries.

The ANDROID_LOG_WRAP mode flag to the android_logger_list_alloc_time() signals logd to quiesce the reader until the buffer is about to prune at the start time then proceed to dumping content.

The ANDROID_LOG_PSTORE mode flag to the android_logger_open() is used to switch from the active logs to the persistent logs from before the last reboot.

The value returned by android_logger_open() can be used as a parameter to the android_logger_clear() function to empty the sub-log.

The value returned by android_logger_open() can be used as a parameter to the android_logger_get_log_(size|readable_size|version) to retrieve the sub-log maximum size, readable size and log buffer format protocol version respectively. android_logger_get_id() returns the id that was used when opening the sub-log.

Errors

If messages fail, a negative error code will be returned to the caller.

The -ENOTCONN return code indicates that the logger daemon is stopped.

The -EBADF return code indicates that the log access point can not be opened, or the log buffer id is out of range.

For the -EAGAIN return code, this means that the logging message was temporarily backed-up either because of Denial Of Service (DOS) logging pressure from some chatty application or service in the Android system, or if too small of a value is set in /proc/sys/net/unix/max_dgram_qlen. To aid in diagnosing the occurence of this, a binary event from liblog will be sent to the log daemon once a new message can get through indicating how many messages were dropped as a result. Please take action to resolve the structural problems at the source.

It is generally not advised for the caller to retry the -EAGAIN return code as this will only make the problem(s) worse and cause your application to temporarily drop to the logger daemon priority, BATCH scheduling policy and background task cgroup. If you require a group of messages to be passed atomically, merge them into one message with embedded newlines to the maximum length LOGGER_ENTRY_MAX_PAYLOAD.

Other return codes from writing operation can be returned. Since the library retries on EINTR, -EINTR should never be returned.