Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8152635

Create a UL class to represent a Log + Level combination

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • None
    • hotspot
    • None
    • svc
    • b115

      I propose that we create a LogTarget class so that we can create a log object representing both a tag set and a tag level.

      With this class we write code as:
      LogTarget(Debug, gc, heap) log;
      if (log.is_enabled()) {
        log.print(...);
        log.print(...);
        ... = log.stream();
      }

      instead of the current model:
      Log(gc, heap) log;
      if (log.is_debug()) {
        log.debug(...)
        log.debug(...)
        ... = log.debug_stream():
      }

      The LogTarget class/macro ensures that we only mention the log level once, so that we don't accidentally log to the wrong level. The previous version forces the coder to repeat 'debug' four times.

            stefank Stefan Karlsson
            stefank Stefan Karlsson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: