<?php

class Log {

  public static function emergency($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_EMERGENCY);
  }

  public static function alert($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_ALERT);
  }

  public static function critical($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_CRITICAL);
  }

  public static function error($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_ERROR);
  }

  public static function warning($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_WARNING);
  }

  public static function notice($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_NOTICE);
  }

  public static function info($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_INFO);
  }

  public static function debug($message, $tag = "") {
    self::invoke_watchdog($message, $tag, WATCHDOG_DEBUG);
  }

  private static function invoke_watchdog($message, $tag, $severity) {
    watchdog($tag, $message, [], $severity);
  }
}

<?php

class Log {

  public static function emergency($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_EMERGENCY);
  }

  public static function alert($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_ALERT);
  }

  public static function critical($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_CRITICAL);
  }

  public static function error($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_ERROR);
  }

  public static function warning($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_WARNING);
  }

  public static function notice($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_NOTICE);
  }

  public static function info($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_INFO);
  }

  public static function debug($tag, $message = "") {
    self::invoke_watchdog($tag, $message, WATCHDOG_DEBUG);
  }

  private static function invoke_watchdog($tag, $message, $severity) {
    if (!$message) { // Only message with no tags
      watchdog("", $tag, [], $severity);
    } else if (is_array($tag)) { // Tags specified as an array
      watchdog(implode($tag, ' '), $message, [], $severity);
    } else { // Tags specified as a string
      watchdog($tag, $message, [], $severity);
    }
  }
}

Improve tag usage in logging helper
Improve tag usage in logging helper

Tags can be now specified before the message. Nice logger automatically
recognices tags specified as a string or as an array.

Closes #2
