一.先看上层

1.1.  布局 KEY

private static final String SELECT_LOGD_SIZE_KEY = "select_logd_size";

private static final String SELECT_LOGD_SIZE_PROPERTY = "persist.logd.size";

1.2. writeLogdSizeOption()

updateLogpersistValues()

private void writeLogdSizeOption(Object newValue) {

boolean disable = (newValue != null) &&

(newValue.toString().equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE));

String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);

if (currentTag == null) {

currentTag = "";

}

// filter clean and unstack all references to our setting

String newTag = currentTag.replaceAll(

",+" + SELECT_LOGD_TAG_SILENCE, "").replaceFirst(

"^" + SELECT_LOGD_TAG_SILENCE + ",*", "").replaceAll(

",+", ",").replaceFirst(

",+$", "");

if (disable) {

newValue = SELECT_LOGD_MINIMUM_SIZE_VALUE;

// Make sure snet_event_log get through first, but do not override

String snetValue = SystemProperties.get(SELECT_LOGD_SNET_TAG_PROPERTY);

if ((snetValue == null) || (snetValue.length() == 0)) {

snetValue = SystemProperties.get(SELECT_LOGD_RUNTIME_SNET_TAG_PROPERTY);

if ((snetValue == null) || (snetValue.length() == 0)) {

SystemProperties.set(SELECT_LOGD_SNET_TAG_PROPERTY, "I");

}

}

// Silence all log sources, security logs notwithstanding

if (newTag.length() != 0) {

newTag = "," + newTag;

}

// Stack settings, stack to help preserve original value

newTag = SELECT_LOGD_TAG_SILENCE + newTag;

}

if (!newTag.equals(currentTag)) {

SystemProperties.set(SELECT_LOGD_TAG_PROPERTY, newTag);

}

String defaultValue = defaultLogdSizeValue();

final String size = ((newValue != null) && (newValue.toString().length() != 0)) ?

newValue.toString() : defaultValue;

SystemProperties.set(SELECT_LOGD_SIZE_PROPERTY, defaultValue.equals(size) ? "" : size);

SystemProperties.set("ctl.start", "logd-reinit");

pokeSystemProperties();

updateLogdSizeValues();

}

private void updateLogdSizeValues() {

if (mLogdSize != null) {

String currentTag = SystemProperties.get(SELECT_LOGD_TAG_PROPERTY);

String currentValue = SystemProperties.get(SELECT_LOGD_SIZE_PROPERTY);

if ((currentTag != null) && currentTag.startsWith(SELECT_LOGD_TAG_SILENCE)) {

currentValue = SELECT_LOGD_OFF_SIZE_MARKER_VALUE;

}

if (mLogpersist != null) {

String currentLogpersistEnable

= SystemProperties.get(ACTUAL_LOGPERSIST_PROPERTY_ENABLE);

if ((currentLogpersistEnable == null)

|| !currentLogpersistEnable.equals("true")

|| currentValue.equals(SELECT_LOGD_OFF_SIZE_MARKER_VALUE)) {

writeLogpersistOption(null, true);

mLogpersist.setEnabled(false);

} else if (mLastEnabledState) {

mLogpersist.setEnabled(true);

}

}

if ((currentValue == null) || (currentValue.length() == 0)) {

currentValue = defaultLogdSizeValue();

}

//gatsby 加载res 资源

String[] values = getResources().getStringArray(R.array.select_logd_size_values);

String[] titles = getResources().getStringArray(R.array.select_logd_size_titles);

int index = 2; // punt to second entry if not found

if (SystemProperties.get("ro.config.low_ram").equals("true")) {

mLogdSize.setEntries(R.array.select_logd_size_lowram_titles);

titles = getResources().getStringArray(R.array.select_logd_size_lowram_titles);

index = 1;

}

String[] summaries = getResources().getStringArray(R.array.select_logd_size_summaries);

for (int i = 0; i < titles.length; i++) {

if (currentValue.equals(values[i])

|| currentValue.equals(titles[i])) {

index = i;

break;

}

}

mLogdSize.setValue(values[index]);

mLogdSize.setSummary(summaries[index]);

mLogdSize.setOnPreferenceChangeListener(this);

}

}

二.LogBuffer.cpp

persist.logd.size

persist.logd.size

ro.logd.size

LOG_BUFFER_SIZE, 即256k

LOG_BUFFER_MIN_SIZE, 即64k

三.默认512K

--- a/frameworks/base/packages/SettingsLib/res/values-zh-rCN/arrays.xml

+++ b/frameworks/base/packages/SettingsLib/res/values-zh-rCN/arrays.xml

@@ -62,6 +62,7 @@

"关闭"

"64K"

"256K"

+ "512K"

"1M"

"4M"

"16M"

@@ -76,6 +77,7 @@

"关闭"

"每个日志缓冲区 64K"

"每个日志缓冲区 256K"

+ "每个日志缓冲区 512K"

"每个日志缓冲区 1M"

"每个日志缓冲区 4M"

"每个日志缓冲区 16M"

diff --git a/frameworks/base/packages/SettingsLib/res/values/arrays.xml b/frameworks/base/packages/SettingsLib/res/values/arrays.xml

old mode 100644

new mode 100755

index 920e061..b57115b

--- a/frameworks/base/packages/SettingsLib/res/values/arrays.xml

+++ b/frameworks/base/packages/SettingsLib/res/values/arrays.xml

@@ -122,6 +122,7 @@

32768

65536

+524288

262144

1048576

4194304

diff --git a/system/core/logd/LogBuffer.cpp b/system/core/logd/LogBuffer.cpp

old mode 100644

new mode 100755

index 0497a89..5a2a597

--- a/system/core/logd/LogBuffer.cpp

+++ b/system/core/logd/LogBuffer.cpp

@@ -97,14 +97,20 @@ void LogBuffer::init() {

static const char global_tuneable[] = "persist.logd.size"; // Settings App

static const char global_default[] = "ro.logd.size"; // BoardConfig.mk

+SLOGE("gatsby LogBuffer init");

+

unsigned long default_size = property_get_size(global_tuneable);

+SLOGE("000 gatsby default_size -> %lu .",default_size);

if (!default_size) {

+SLOGE("000 gatsby !!!default_size aaa -> %lu .",default_size);

default_size = property_get_size(global_default);

+SLOGE("000 gatsby !!!default_size bbb -> %lu .",default_size);

if (!default_size) {

default_size = property_get_bool("ro.config.low_ram",

BOOL_DEFAULT_FALSE)

? LOG_BUFFER_MIN_SIZE // 64K

: LOG_BUFFER_SIZE; // 256K

+SLOGE("000 gatsby !!!!!default_size ccc -> %lu .",default_size);

}

}

@@ -116,24 +122,32 @@ void LogBuffer::init() {

snprintf(key, sizeof(key), "%s.%s",

global_tuneable, android_log_id_to_name(i));

+//getprop persist.logd.size

unsigned long property_size = property_get_size(key);

if (!property_size) {

snprintf(key, sizeof(key), "%s.%s",

global_default, android_log_id_to_name(i));

property_size = property_get_size(key);

+SLOGE("111 gatsby global_tuneable -> %s . android_log_id_to_name(i) -> %s .",global_tuneable,android_log_id_to_name(i));

+SLOGE("111 gatsby property_size -> %lu .",property_size);

}

if (!property_size) {

property_size = default_size;

+SLOGE("2222 gatsby property_size -> %lu .",property_size);

}

if (!property_size) {

+//256k

property_size = LOG_BUFFER_SIZE;

+SLOGE("333 gatsby property_size -> %lu .",property_size);

}

if (setSize(i, property_size)) {

+//64k

setSize(i, LOG_BUFFER_MIN_SIZE);

+SLOGE("444 gatsby property_size -> %lu .",property_size);

}

}

bool lastMonotonic = monotonic;

android log.d 格式化,Android7.1 logd 日志记录缓冲区大小相关推荐

  1. android log缓冲区大小,科普:开发者模式日志记录缓冲区到底怎样设置

    概念: 志缓冲区是小型的.用于短期存储将写入到磁盘上的重做日志的变更向量的临时区域."变更向量"是应用于某些对象的修改,执行DML语句会生成应用于数据的变更向量.有了重做日志,数据 ...

  2. java common log使用,log4j和commons.logging日志记录的使用方法

    # re: log4j和commons.logging日志记录的使用方法 2008-03-11 14:08 芦苇 一 最好与commons-logging一起用,why? 1.标准接口,即使将来脱离了 ...

  3. 74. 学会使用 SAP ABAP Application Log 在代码里添加应用日志记录功能

    文章目录 ABAP 应用日志对象的概念和创建 如何创建需要通过应用日志记录的消息(message) 使用应用日志创建 API 进行日志记录的创建 使用事物码 SLG1 查看生成的应用日志内容 总结 笔 ...

  4. android log.d 格式化,android – 在我的代码中使用Log.d()或Log.e()

    考虑使用它: isLoggable() Checks to see whether or not a log for the specified tag is loggable at the spec ...

  5. android log系统

    转载自http://blog.csdn.net/Luoshengyang/article/category/838604/3 Android系统开发中LOG的使用 在程序开发过程中,LOG是广泛使用的 ...

  6. Java学习day051 记录日志(基本日志、高级日志、修改日志管理器配置、本地化、处理器、过滤器、格式化器、日志记录说明)

    使用的教材是java核心技术卷1,我将跟着这本书的章节同时配合视频资源来进行学习基础java知识. day051   记录日志(基本日志.高级日志.修改日志管理器配置.本地化.处理器.过滤器.格式化器 ...

  7. windows log日志分割_如何将日志记录到 Windows事件日志 中

    每当出现一些未捕获异常时,操作系统都会将异常信息写入到 Windows 事件日志 中,可以通过 Windows 事件查看器 查看,如下图: 这篇文章将会讨论如何使用编程的方式将日志记录到 Window ...

  8. TinyLog –轻量级Java日志记录框架教程

    TinyLog is a simple and lightweight logging framework for Java. We can use tinylog with Java, Kotlin ...

  9. 配置Haproxy增加日志记录功能

    2019独角兽企业重金招聘Python工程师标准>>> CentOS 7上yum安装的Haproxy,默认没有记录日志.需要做一下配置才能记录日志. 1.创建日志文件/var/log ...

最新文章

  1. 我的机器学习和深度学习绘图模板.pptx
  2. mclmcrrt77 matlab,mclmcrrt77.dll下载
  3. aPaaS将如何改变软件行业?
  4. 腾讯“抢”小米黑鲨做元宇宙?
  5. 产品经理适合当项目经理吗?
  6. 联想小新潮7000黑苹果教程_联想小新潮7000-15笔记本安装win10系统操作教程
  7. c语言程序设计2020年版,2020年新版c语言程序设计题库.docx
  8. 计算机组成与结构知识点总结
  9. 天线的布局、基本术语、种类、隔离度设计要求介绍
  10. tftd32搭建DHCP服务器软件打开报错
  11. matlab 合成t检验,[zz]用MATLAB做T检验(ttest)
  12. 锁定计算机后等于睡眠吗,详细教你电脑休眠和睡眠的区别
  13. WebService CXF-RS技术之@Pathparam与@Queryparam注解区别
  14. “eclipse”出现异常,“install new software”工具 无法使用,提示“Operation cannot be completed”错误的解决方案。
  15. 前端2020面试题195道
  16. 蓝旭后端第六次培训课 MySQL(二)
  17. [Flask] [Python3] 第一个flask APP
  18. 关于python小游戏的毕业论文_使用Python写一个小游戏
  19. 网易视频云分享:最佳日志实践
  20. csgo账号连接服务器错误,steam csgo连接服务器发生错误 | 手游网游页游攻略大全...

热门文章

  1. 相似度系列9: unify USR: An Unsupervised and Reference Free Evaluation Metric for Dialog Generation
  2. ubuntu截图工具ksnapshot安装
  3. 亚太融媒|中国品牌网全球、APEC生活+「设计师宇宙」环保熊猫小保保2022贺岁 | 稳略产业基金观察
  4. Java之路:映射(Map)
  5. 如何准备PMP考试重点知识问答
  6. oracle统计函数
  7. R读取SPSS文件(.sav)
  8. 这款 AI 生成文本工具几分钟即可生成数月社交媒体内容? #Jasper AI
  9. CI/CD: GitLab Runner安装注册配置管理
  10. 女生学大数据开发有什么优势呢?