X-Received: by 10.224.175.65 with SMTP id w1mr5768338qaz.7.1359266701049; Sat, 26 Jan 2013 22:05:01 -0800 (PST) X-Received: by 10.49.71.169 with SMTP id w9mr2037531qeu.7.1359266700858; Sat, 26 Jan 2013 22:05:00 -0800 (PST) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!p13no5365522qai.0!news-out.google.com!k2ni2734qap.0!nntp.google.com!p13no5365515qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.java.programmer Date: Sat, 26 Jan 2013 22:05:00 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=217.172.23.24; posting-account=Z-5a_wkAAABTzN1pAiC7xNW_xfTNp2Vr NNTP-Posting-Host: 217.172.23.24 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <0cfefb99-94f9-44e0-9b58-926818a9560d@googlegroups.com> Subject: ultralog: new concept of logging API From: Mikhail Vladimirov Injection-Date: Sun, 27 Jan 2013 06:05:00 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.java.programmer:21790 Hello, Java developers community. Let me present "ultralog" project (http://code.google.com/p/ultralog/) which main purpose is to demonstrate new concept of how logging APIs could be structured. The idea is that each logger in the application has its own interface specific to the purpose of the logger. This interface defines all messages that could be logged via this logger. Here is an example of such interface: protected interface HelloLogger extends BasicLogger { @LogMessage (level = INFO, template = "Hello, ${1}!") void hello (String user); } The logging framework generates implementations of such interfaces on the fly or at compile time by compiling message templates into Java bytecode. Here is how this logger could be used: HelloLogger logger = LoggerManager.createLogger (HelloLogger.class); if (logger.isInfoEnabled ()) logger.hello (System.getProperty ("user.name")); Advantages of this approach: - Clear syntax. - All log messages for the logger are defined in one place which makes it easier to review and restyle them in consistent manner. - Log messages are defined as methods, so IDEs "find references" feature could be used to fine all places where particular message is logged. - Values of arbitrary types including primitive types could be substituted into log message without allocating any temporary objects. See project WiKi (http://code.google.com/p/ultralog/wiki/TableOfContents) for more information and feel free to provide feedback. -- Mikhail Vladimirov