Skip to content

Logging DSL #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 29, 2017
Merged

Logging DSL #6

merged 7 commits into from
May 29, 2017

Conversation

thekid
Copy link
Member

@thekid thekid commented May 29, 2017

Example

// Before
$cat= (new LogCategory())->withAppender(new ColoredConsoleAppender());

// New
$cat= Logging::all()->toConsole();

Modifying category, level and layout

// Set category
$cat= Logging::named('sql')->toFile('sql.log');

// Change level
$cat= Logging::of(LogLevel::ERROR | LogLevel::WARN)->toConsole();

// Change layout
$cat= Logging::using(new PatternLayout('...'))->toSyslog(LOG_USER);

API

public abstract class util.log.Logging {

  // Default
  public static util.log.LogSetup all()

  // Shorthands
  public static util.log.LogSetup named(string $category)
  public static util.log.LogSetup of(int $level)
  public static util.log.LogSetup using(util.log.Layout $layout)
}

public class util.log.LogSetup implements lang.Value {

  // Fluent interface
  public util.log.LogSetup named(string $category)
  public util.log.LogSetup of(string $level)
  public util.log.LogSetup using(util.log.Layout $layout)

  // Create categories
  public util.log.LogCategory to(util.log.Appender... $appenders)
  public util.log.LogCategory toConsole(bool $colors)
  public util.log.LogCategory toFile(string|io.Path|io.File $file)
  public util.log.LogCategory toSyslog(int $facility, string $identifier)

  // Value implementation
  public string toString()
  public string hashCode()
  public int compareTo(var $value)
}

@thekid thekid merged commit b2b8a73 into master May 29, 2017
@thekid thekid deleted the feature/logging branch May 29, 2017 21:25
@thekid
Copy link
Member Author

thekid commented May 29, 2017

@thekid thekid mentioned this pull request Aug 10, 2018
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant