Skip to content
Permalink
Browse files

Merge pull request #276 from hanami/clean-up-275

Clean up #275
  • Loading branch information...
jodosha committed Feb 14, 2017
2 parents 49e2d67 + 90f7aca commit dddad16c893a3dab3fe7ad432b3552d7a849c195
@@ -8,30 +8,30 @@ excerpt: >
Feature freeze, project logger, automatic logging of requests, SQL queries, and migrations. Minor bug fixes.
---

This `v1.0.0.beta1` release introduces Hanami [feature freeze](https://en.wikipedia.org/wiki/Freeze_(software_engineering)) for 1.0, alongside with a couple of features, and a few bug fixes.
This `v1.0.0.beta1` release marks Hanami's [feature freeze](https://en.wikipedia.org/wiki/Freeze_(software_engineering)) for 1.0, along with a couple new features, and a few bug fixes.

Since now on, **Hanami API's are stable and won't be changed until 2.0**.
From now on, **Hanami API's are stable and won't be changed until 2.0**.

The stable release (`v1.0.0`) will happen between the end of March and the beginning of April 2017, which coincides with the [Hanami season in Japan](http://www.japan-guide.com/sakura/). 🌸

In the meantime we'll release other _beta_ and _release candidate_ versions.
Between now and then, we'll release other _beta_ and _release candidate_ versions.

## Features

Hanami is now compatible with Ruby 2.3+ (including the latest 2.4) and with Rack 2.0 only.

### Project Logger

We introduced the project logger, available at `Hanami.logger`.
If you need to log an information, use it like this: `Hanami.logger.debug "hello"`.
We added the project logger, available at `Hanami.logger`.
If you need to log a piece of information, use it like this: `Hanami.logger.debug "hello"`.

Because of this change, the application loggers were removed (eg. `Web.logger`, `Admin.logger`).
The logger settings for each single application are not supported anymore (eg. `apps/web/application.rb`).
In order to configure the logger, please edit `config/environment.rb`.
Because of this change, the application-specific loggers were removed (eg. `Web.logger`, `Admin.logger`).
Therefore, logger settings for individual application are not supported anymore (e.g. inside `apps/web/application.rb`).
To configure the logger, please edit `config/environment.rb`.

### Automatic Logging

A project that uses Hanami will automatically log each incoming HTTP request, SQL queries and migrations output.
A project that uses Hanami will automatically log each incoming HTTP request, SQL query and migration.

When a project is used in development mode, the logging format is human readable:

@@ -40,8 +40,8 @@ When a project is used in development mode, the logging format is human readable
[bookshelf] [INFO] [2017-02-11 15:42:48 +0100] (0.000381s) SELECT "id", "title", "created_at", "updated_at" FROM "books" WHERE ("book"."id" = '1') ORDER BY "books"."id"
```

For production environment, the default format is JSON.
JSON is parseable and more machine oriented. It works great with log aggregators or SaaS logging products.
For the production environment, the default format is **JSON** instead.
JSON is parseable and more machine-oriented. It works great with log aggregators or SaaS logging products.

```json
{"app":"bookshelf","severity":"INFO","time":"2017-02-10T22:31:51Z","http":"HTTP/1.1","verb":"GET","status":"200","ip":"127.0.0.1","path":"/books/1","query":"","length":"451","elapsed":0.000391478}
@@ -99,7 +99,8 @@ Hanami.boot
```

This is useful to boot a Hanami project **outside of** the server or the console.
A typical use case is [Sidekiq](http://sidekiq.org). If you want to run background jobs with this queue, you can start the process with:
A typical use case is [Sidekiq](http://sidekiq.org).
If you want to run background jobs with this queue, you can start the process with:

```shell
bundle exec sidekiq -r ./config/boot.rb
@@ -90,7 +90,7 @@ Generate an entity and a repository with a single command
create spec/bookshelf/repositories/book_repository_spec.rb
```

It generates an entity with the corresponding repository, migration, and testing code.
It generates an entity with the corresponding repository, migration, and tests.

The migration will already contain the code for the creation of the table, the primary key and the timestamps:

@@ -351,7 +351,7 @@ Enter entities and repositories:
* an **entity** is a domain object (eg. `Book`) uniquely identified by its identity.
* a **repository** mediates between entities and the persistence layer.

Entities are totally unaware of database.
Entities are totally unaware of the database.
This makes them **lightweight** and **easy to test**.

For this reason we need a repository to persist the data that a `Book` depends on.
@@ -372,8 +372,7 @@ The generator gives us an entity, a repository, a migration, and accompanying te

### Migrations To Change Our Database Schema

As first thing, we need to shape our database table, by editing the migration:

Let's modify the generated migration to include `title` and `author` fields:

```ruby
# db/migrations/20161115110038_create_books.rb
@@ -65,7 +65,7 @@ Hanami.configure do
# ...
mailer do
root Hanami.root.join("lib", "kaba", "mailers")
root Hanami.root.join("lib", "bookshelf", "mailers")
# See http://hanamirb.org/guides/mailers/delivery
delivery :test
@@ -4,7 +4,7 @@ title: Guides - Logging

# Logging

A project has a global logger available at `Hanami.logger` that can be used like this: `Hanami.logger.debug "Hello"`
Each project has a global logger available at `Hanami.logger` that can be used like this: `Hanami.logger.debug "Hello"`

It can be configured in `config/environment.rb`

@@ -33,7 +33,7 @@ If you want to use a file, pass `stream: 'path/to/file.log'` as an option.

## Automatic Logging

All the HTTP requests, SQL queries, and database operations are automatically logged.
All HTTP requests, SQL queries, and database operations are automatically logged.

When a project is used in development mode, the logging format is human readable:

@@ -43,7 +43,7 @@ When a project is used in development mode, the logging format is human readable
```

For production environment, the default format is JSON.
JSON is parseable and more machine oriented. It works great with log aggregators or SaaS logging products.
JSON is parseable and more machine-oriented. It works great with log aggregators or SaaS logging products.

```json
{"app":"bookshelf","severity":"INFO","time":"2017-02-10T22:31:51Z","http":"HTTP/1.1","verb":"GET","status":"200","ip":"127.0.0.1","path":"/books/1","query":"","length":"451","elapsed":0.000391478}

0 comments on commit dddad16

Please sign in to comment.
You can’t perform that action at this time.