<commit_before># Foreman

Foreman is a Minecraft server wrapper.

## Logging

Subscribe _logging adapters_ to a `Foreman::Server` to do things with log messages, such as write them to the standard output stream, a file, or a remote logging service. A logging adapter is any object which responds to `log(level, uuid, time, message, options)`:

* `level` -- One of `Foreman::Logging::LEVELS` (`:debug`, `:info`, `:warn`, `:error`, `:fatal`).
* `uuid` -- A unique identifier string for the log message. Useful for identifying the message across different logging systems.
* `time` -- A uniform `Time` for the log message. Useful if you'd like disparate logging adapters to log the message with the same timestamp, even if not all adapters receive the message simultaneously.
* `message` -- The log message.
* `options` -- A hash containing any options originally passed to `Foreman::Server#logger#log`. Useful for attaching structured data to the log message in addition to the human-readable string. A Splunk logging adapter, for instance, might process the contents of `options` as [Splunk event fields](http://docs.splunk.com/Splexicon:Field).

Use `Foreman::Server#logger#subscribe` to subscribe a logging adapter:

```ruby
server = Foreman::Server.new
server.logger.subscribe Foreman::Logging::StdoutAdapter.new
```

If given a block, `subscribe` yields the adapter, which is a useful method of configuration:

```ruby
server = Foreman::Server.new
server.logger.subscribe Foreman::Logging::StdoutAdapter.new do |adapter|
  adapter.level = :debug
end
```

If the logging adapter responds to `subscribed(multiplexer)`, the multiplexer will call that method, passing itself as an argument, after the adapter is subscribed. Adapters can use this to access the logging multiplexer and the Foreman server:

```ruby
class SimpleLoggingAdapter
  def log(level, uuid, time, message, options)
    # ...
  end

  def subscribed(multiplexer)
    @multiplexer = multiplexer # => #<Foreman::Server:0x007fdf72197338 ...>
  end
end
```<commit_msg>Clarify logging overview in readme<commit_after># Foreman

Foreman is a Minecraft server wrapper.

## Logging

Foreman's logging mechanism allows you to send Minecraft server log messages to any number of destinations. For instance, you might want to log informative messages such as player joins to a local file, and send debug messages, warnings and errors to [Splunk](http://splunk.com/) for later analysis.

Subscribe _logging adapters_ to a Foreman server to do things with log messages, such as write them to the standard output stream, a file, or a remote logging service. A logging adapter is any object which responds to `log(level, uuid, time, message, options)`:

* `level` -- One of `Foreman::Logging::LEVELS` (`:debug`, `:info`, `:warn`, `:error`, `:fatal`).
* `uuid` -- A unique identifier string for the log message. Useful for identifying the message across different logging systems.
* `time` -- A uniform `Time` for the log message. Useful if you'd like disparate logging adapters to log the message with the same timestamp, even if not all adapters receive the message simultaneously.
* `message` -- The log message.
* `options` -- A hash containing any options originally passed to `Foreman::Server#logger#log`. Useful for attaching structured data to the log message in addition to the human-readable string. A Splunk logging adapter, for instance, might process the contents of `options` as [Splunk event fields](http://docs.splunk.com/Splexicon:Field).

Use `Foreman::Server#logger#subscribe` to subscribe a logging adapter:

```ruby
server = Foreman::Server.new
server.logger.subscribe Foreman::Logging::StdoutAdapter.new
```

If given a block, `subscribe` yields the adapter, which is a useful method of configuration:

```ruby
server = Foreman::Server.new
server.logger.subscribe Foreman::Logging::StdoutAdapter.new do |adapter|
  adapter.level = :debug
end
```

If the logging adapter responds to `subscribed(multiplexer)`, the server's logging multiplexer will call that method, passing itself as an argument, after the adapter is subscribed. Adapters can use this to access the multiplexer and, therefore, the Foreman server:

```ruby
class SimpleLoggingAdapter
  def log(level, uuid, time, message, options)
    # ...
  end

  def subscribed(multiplexer)
    multiplexer.foreman # => #<Foreman::Server:0x007fdf72197338 ...>
  end
end
```
{'fraction_non_alphanumeric': 0.0952056350829357, 'fraction_numerical': 0.0054533060668029995, 'mean_word_length': 4.9728629579375845, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '272558', 'n_tokens_mistral': 1247, 'n_tokens_neox': 1171, 'n_words': 541}