<commit_before># Imprint

Imprint helps track requests across multiple log lines or applications. It consists of a lightweight class and middleware to help set tracing ids.

It also has a file which can be used to bootstrap default rails logging to embedding the imprint `trace_id` on each line logged.

Supporting tracing between applications requires updating client calls between applications, at the moment we don't try to monkey patch any of that in and expect responsible clients to add the header manually as described in the Usage section below.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'imprint'
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:

```bash
$ gem install imprint
```

## Usage

After installing the gems and requiring them if needed.

To configure in a Rails 2, 3, or 4 application

edit `config/application.rb` and append the line below

```ruby
require 'imprint/rails_logger'
```

create or update your middleware configuration (for example: `config/initializers/middleware.rb`)

```ruby
require 'imprint'

Rails.application.config.middleware.insert_before Rails::Rack::Logger, Imprint::Middleware
```

If you are using any additional loggers that you wanted tagged that are not part of the normal Rails.logger you should update them as well. For example, we have some scribe logs:

```ruby
def log(message = nil, severity = :info)
  mirror_logger.add(parse_severity(severity), message) if mirror_logger
  log_raw(message, severity) do
    message = yield if block_given?
    # append imprint trace
    if (defined?(Imprint::Middleware.get_trace_id)) && message && message.is_a?(String) && message.length > 1 && Imprint::Middleware.get_trace_id.get_trace_id.to_s != '-1'
      message = "#{message}\n" unless message[-1] == "\n"
      message = message.gsub("\n"," [trace_id=#{Imprint::Middleware.get_trace_id}]\n")
    end
    format = []<commit_msg>update readme to match latest release<commit_after># Imprint

Imprint helps track requests across multiple log lines or applications. It consists of a lightweight class and middleware to help set tracing ids.

It also has a file which can be used to bootstrap default rails logging to embedding the imprint `trace_id` on each line logged.

Supporting tracing between applications requires updating client calls between applications, at the moment we don't try to monkey patch any of that in and expect responsible clients to add the header manually as described in the Usage section below.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'imprint'
```

And then execute:

```bash
$ bundle
```

Or install it yourself as:

```bash
$ gem install imprint
```

## Usage

After installing the gems and requiring them if needed.

To configure in a Rails 2, 3, or 4 application

edit `config/application.rb` and append the line below

```ruby
require 'imprint/rails_logger'
```

create or update your middleware configuration (for example: `config/initializers/middleware.rb`)

```ruby
require 'imprint'

Rails.application.config.middleware.insert_before Rails::Rack::Logger, Imprint::Middleware
```

If you are using any additional loggers that you wanted tagged that are not part of the normal Rails.logger you should update them as well. For example, we have some scribe logs:

```ruby
def log(message = nil, severity = :info)
  mirror_logger.add(parse_severity(severity), message) if mirror_logger
  log_raw(message, severity) do
    message = yield if block_given?
    # append imprint trace
    if (defined?(Imprint::Tracer.get_trace_id)) && message && message.is_a?(String) && message.length > 1 && Imprint::Tracer.get_trace_id.get_trace_id
      message = "#{message}\n" unless message[-1] == "\n"
      message = message.gsub("\n"," [trace_id=#{Imprint::Middleware.get_trace_id}]\n")
    end
    format = []
{'fraction_non_alphanumeric': 0.0914492379230173, 'fraction_numerical': 0.0028416429863084474, 'mean_word_length': 4.710914454277286, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1808589', 'n_tokens_mistral': 1139, 'n_tokens_neox': 1060, 'n_words': 458}