登录J2ME

编程入门 行业动态 更新时间:2024-10-11 07:35:46
本文介绍了登录J2ME的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

j2me存在哪些日志记录解决方案?

What logging solutions exist for j2me?

我特别希望轻松排除发行"版本的日志记录,以拥有更小的软件包和&内存占用量.

I'm specifically interested in easily excluding logging for "release" version, to have a smaller package & memory footprint.

推荐答案

如果您通过Proguard使用预处理和模糊处理,则可以拥有一个简单的日志记录类.

If you are using preprocessing and obfuscation with Proguard, then you can have a simple logging class.

public class Log { public static void debug(final String message) { //#if !release.build System.out.println(message); //#endif } }

或者在需要的地方进行日志记录.现在,如果release.build属性设置为true,则该代码将被注释掉,这将导致一个空方法. Proguard将删除所有使用空方法的方法-实际上,发布版本将删除所有调试消息.

Or do logging where ever you need to. Now, if release.build property is set to true, this code will be commented out, that will result in an empty method. Proguard will remove all usages of empty method - In effect release build will have all debug messages removed.

关于库级别的思考(我正在研究J2ME库的映射),我可能已经找到了更好的解决方案.

Thinking about it on library level (I'm working on mapping J2ME library) I have, probably, found a better solution.

public class Log { private static boolean showDebug; public static void debug(final String message) { if (showDebug) { System.out.println(message); } } public static void setShowDebug(final boolean show) { showDebug = show; } }

通过这种方式,最终开发人员可以在他/她感兴趣的库中启用日志级别.如果什么都不启用,则在最终产品混淆中将删除所有日志记录代码.甜:)

This way end developer can enable log levels inside library that he/she is interested in. If nothing will be enabled, all logging code will be removed in end product obfuscation. Sweet :)

/JaanusSiim

/JaanusSiim

更多推荐

登录J2ME

本文发布于:2023-11-27 22:46:19,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639915.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:J2ME

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!