rodionmoiseev / c10n

A Java library, focused on making internationalisation more modular, easier to evolve and maintain, robust-to-change and IDE-friendly without excess of external tools.
Apache License 2.0
67 stars 10 forks source link

Create a logging plugin #34

Closed rodionmoiseev closed 8 years ago

rodionmoiseev commented 8 years ago

With the new plugin system (See #31) it would be possible to perform logging, backed by a custom logging framework (e.g. Log4j, Logback, etc.)

@Logger("my-logger")
@C10NMessages
interface LoggingTest{

  /**
   * Optional explanation on what this log is.
   *
   * @param user Optional explanation by parameter
   */
  @En("User {0} has attempted to login from {1}")
  @Ja("{0}ユーザが{1}からログインしました")/*optional japanese*/
  @Level(INFO)
  @Custom("Add custom metadata like error-codes")
  void userLoginAttempt(String user, String ipAddress);

  @En("Something nasty happened")
  @Level(WARN)
  void oops(Throwable cause);
}

The above interface would be instantiated through c10n as usual, but would result in the message being logged to the given logger.

Additional annotations could be setup for each method to control logging behaviour, such as the logging level, logger name, or some custom MDC