Skip to content
This repository was archived by the owner on Dec 8, 2020. It is now read-only.

Commit d2b1018

Browse files
3.0.0 Release (#314)
* Prepare 3.0 development This commit is designed to prepare for 3.0+ development. In Timber Elixir 3.0+, integration with other libraries will be done through additional libraries in order to allow for better dependency management and compilation guarantees. Timber Elixir 3.0+ will be required for Elixir 1.7+ support. All of the integration-specific code has been removed except for the installer code. The installer code needs to be updated to appropriately update the mix.exs files with the relevant integration libraries and use the updated module names. The weird dependency listing logic has been removed from mix.exs. The README has also been fixed so that the markdown now renders correctly. This fixes the .formatter.exs file to look at the root `lib` folder. This change adds Elixir 1.7.2 to the list of versions that Travis tests for. Addresses #298, fixes #209, fixes #162 * Change supported Elixir versions to ~> 1.4 The Timber library will now only support Elixir versions 1.4 and higher. To use Timber with Elixir 1.3 (which support was removed for), please use a release from the 2.x branch. Supporting only Elixir 1.4+ will allow us to take advantage of the new Jason library which is easier to maintain support for. * Remove installer This removes the installer. This decision was made because the installer, while valuable, is difficult to maintain and has introduced a number of bugs for end-users. Manual installation is now the preferred method. * Clean up and organize documentation This organizes the documentation by providing groupings for the events and contexts so they appear under headers in the ExDoc rendering. It also moves some of the internal helper modules to not expose any documentation. * Remove Timber.CurrentContext module The Timber.CurrentContext module is deprecated and was slated for removal in the 3.x line. Its usecase is now handled by Timber.LocalContext. * Provide InMemory Logger backend for testing This provides the InMemory Logger backend for testing purposes. The InMemory backend was previously only available as the TestLoggerBackend as a test support module. This moves the module to the library code (instead of test support code) so any code dependent on the library can utilize the InMemory logger. The InMemory logger is only intended to be used for testing dependent libraries, not for production use. * Remove unused macro skip_min_elixir_version/1 This removes the unused macro skip_min_elixir_version/1 which was only used for testing the exceptions integration. This has now been moved to the exceptions integration library. * Remove unused helper function parse_log_line/1 This removes the unused test helper function `parse_log_line/1`. * Move FakeHTTPClient to Timber.HTTPClients.Fake This makes the FakeHTTPClient, which was a testing support module, to Timber.HTTPClients.Fake so that it can be utilized by dependent code for testing. * Add Test Helpers documentation group This adds the Test Helpers documentation group to properly contain the Timber.HTTPClients.Fake and Timber.LoggerBackends.InMemory modules which are designed for dependent code to test with and not for use with production code. * Prepare 3.0.0-alpha.2 release This increments the version of the library to prepare the 3.0.0-alpha.2 release which is needed by the new exceptions library. It fixes some inconsistencies in the available test helpers for code dependent on the library. * Clean up configuration files This cleans up the config.exs to consolidate configuration blocks and remove unused keys. * Use the Jason library for JSON encoding This changes the JSON encoding paths to use Jason instead of Poison. Like Poison, Jason is a pure Elixir JSON library, but it has a focus on standards compliance and speed. It is intended to become the default JSON library on a number of large Elixir projects including Phoenix. Although Poison 4 was recently released, Poison lingered for nearly a year without critical bug fixes being addressed. Poison's interface was also inconsistent and poorly documented for error cases. With the switch to Jason, Elixir 1.3 and below can no longer be supported since Jason relies on Elixir 1.4 and above. This also removes the ability for the end-developer to inject the JSON library via configuration. While this is a nice concept in theory, it also introduced the strong chance the library would not correspond to the expected behavior of the Timber library logic. Removing this ability ensures we know what is happening in critical code paths. As part of this change, I had to address the fact that some tests hard-coded expected JSON output. Poison output small maps as JSON with a deterministic key order, so tests passed when using Poison, but the library did not publicize this as a guarantee. Jason does not have the same determinism for small maps. I changed these tests to decode the JSON payload and test membership and content. * Remove support for msgpax 1.x This removes support for msgpax 1.x. The 2.x line introduces a number of benefits including better error messaging and optimized packing. Continuing to support the 1.x line introduces too much complexity and variation in what can go wrong with such a critical dependency. * Format changelog This updates the changelog to break some run-on lines * Prepare v3.0.0-alpha.3 release * Remove unused configuration functions This removes configuration functions that were previously used for integrations and thus are no longer required in the core library. * Automatically post test coverage results to Coveralls This uses `mix coveralls.travis` to automatically post test coverage information to Coveralls using Travis' built-in authentication mechanism. * Fix automatic posting of Coveralls report This fixes an error where the incorrect command to generate the coveralls report was called. * Reduce max buffer size to 1000 This reduces the max buffer size to 1000 from 5000 to adhere to the Timber library specification. * Updates the user-agent field for HTTP requests This updates the user-agent field for HTTP requests to comply with the Timber library specification. So the user-agent field will now appear as `timber-elixir/3.0.0-alpha.3` instead of `Timber Elixir/3.0.0-alpha.3 (HTTP)`. * Add InchEx for documentation analysis This adds InchEx for documentation analysis. This is used to check compliance with the Timber library specification. * Fix Credo errors This fixes files to bring them inline with Credo expectations. It also adds Credo to the Travis runs. Additionally, the exception module `Timber.LoggerBackends.HTTP.TimberAPIKeyInvalid` is renamed to `Timber.InvalidAPIKeyError` in order to comply with Elixir module naming rules for exception modules (i.e., they need to end in `Error`). It is also appropriate that it is its own module rather than being nested inside the HTTP backend. * Add adherence document for the Timber library specification This adds the adherence document for the Timber library specification which is a checklist based on the specification. * Make Timber.LocalContext public again The Timber.LocalContext module is actually supposed to be public and it was my mistake to make it ostensibly private by removing the @moduledoc. Users are expected to use the get/0 and save/1 functions to transfer context across process boundaries. * update for 3.0.0 release * restrict inch_ex version * format file
1 parent a26496c commit d2b1018

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+529
-5842
lines changed

.formatter.exs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[
2-
inputs: ["mix.exs", "apps/*/{config,lib,test}/**/*.{ex,exs}"]
3-
]
2+
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
3+
]

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
# Where 3rd-party dependencies like ExDoc output generated docs.
1313
/doc
1414

15+
# Inchex stores some metadata here
16+
/docs
17+
1518
# If the VM crashes, it generates a dump, let's ignore it too.
1619
erl_crash.dump
1720

@@ -22,4 +25,4 @@ erl_crash.dump
2225
/logs
2326

2427
config/*.secret.exs
25-
mix.lock
28+
mix.lock

.tool-versions

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
elixir 1.3.3
1+
elixir 1.6.6
22
erlang 19.1

.travis.yml

+3-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
---
22
language: elixir
33
elixir:
4+
- 1.7.2
45
- 1.6.6
56
- 1.5
67
- 1.4
7-
- 1.3
88
otp_release:
99
- 21.0
1010
- 20.3
1111
- 19.3
1212
- 18.3
13-
env:
14-
matrix:
15-
- NO_THIRD_PARTY_INTEGRATION_TEST=true
16-
- NO_THIRD_PARTY_INTEGRATION_TEST=false
1713

1814
matrix:
1915
exclude:
20-
- elixir: 1.3
21-
otp_release: 20.3
22-
- elixir: 1.3
23-
otp_release: 21.0
2416
- elixir: 1.4
2517
otp_release: 21.0
2618
- elixir: 1.5
@@ -34,6 +26,8 @@ script:
3426
- if [ "$TRAVIS_ELIXIR_VERSION" = "1.6.6" ]; then mix format --check-formatted --dry-run; fi
3527
- MIX_ENV=test mix compile && mix test
3628
- if [ "$TRAVIS_ELIXIR_VERSION" = "1.6.6" ] && [ "$TRAVIS_OTP_RELEASE" = "21.0" ]; then mix dialyzer; fi
29+
- if [ "$TRAVIS_ELIXIR_VERSION" = "1.6.6" ] && [ "$TRAVIS_OTP_RELEASE" = "21.0" ]; then mix coveralls.travis; fi
30+
- if [ "$TRAVIS_ELIXIR_VERSION" = "1.6.6" ] && [ "$TRAVIS_OTP_RELEASE" = "21.0" ]; then mix credo; fi
3731

3832
cache:
3933
directories:

ADHERENCE.md

+108
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Timber Specification Adherence
2+
3+
Audits adherence to the [Timber library specification](timber_library_specification).
4+
5+
* Version: 3.0.0-alpha.3
6+
* Last checked: 2018-10-16
7+
* Checked by: David Antaramian
8+
9+
## Caveats
10+
11+
### Styling
12+
13+
The official `mix format` tool is used for formatting code. All other styling
14+
should follow the `mix credo` guidelines which are controlled by `.credo.exs`.
15+
16+
### Documentation Coverage
17+
18+
Documentation coverage is determined using the `mix inch` tool which reports on
19+
documentation coverage and quality.
20+
21+
## v1.0.0 - Basic Logging
22+
23+
| Sec | Requirement | |
24+
|--------:|:------------------------------------------------------------------|:----|
25+
| **2.** | **Library, Code, and Language Convention** | |
26+
| 2.1 | Library is named `timber` | [x] |
27+
| 2.2 | Follows recommended language conventions | [x] |
28+
| 2.3 | Implements an official styling standard | [x] |
29+
| 2.4 | All public classes and/or modules are documented properly | [ ] |
30+
| 2.4 | All public methods are documented properly | [ ] |
31+
| 2.4 | Method arguments are documented, including options | [ ] |
32+
| 2.4 | Examples are provided in documentation where relevant | [ ] |
33+
| 2.5 | Is semantically versioned | [x] |
34+
| 2.6 | Includes a properly formatted CHANGELOG | [x] |
35+
| 2.7 | Has been made available on the proper package manager | [x] |
36+
| **3.** | **Logging Pipeline** | |
37+
| 3.1 | Properly integrates within the context of the language | [x] |
38+
| 3.1 | Provides separate libraries if integrating with 3rd party loggers | N/A |
39+
| 3.1 | Can be easily swapped into existing applications | [x] |
40+
| 3.2.1 | Exposes leveled methods (info, warn, etc) | N/A |
41+
| 3.2.2 | Accepts generic string log messages | [x] |
42+
| 3.3.2 | Can write logs to any IO device | N/A |
43+
| 3.3.3 | Provides a generic HTTP writer that transmits logs | [x] |
44+
| 3.3.3.1 | Sends logs in batches to the Timber service | [x] |
45+
| 3.3.3.1 | The maxmimum batch flush size default is 1000 | [x] |
46+
| 3.3.3.1 | The maxmimum batch flush size is configurable | [x] |
47+
| 3.3.3.1 | The maxmimum batch flush age default is 1 second | [x] |
48+
| 3.3.3.1 | The maxmimum batch flush age is configurable | [x] |
49+
| 3.3.3.1 | Log lines can be buffered after a flush starts | [x] |
50+
| 3.3.3.1 | Flush errors do not affect the stability of the system | [x] |
51+
| 3.3.3.1 | Flush errors do not pause or stop the process in any way | [x] |
52+
| 3.3.3.1 | Request that results in 5XX responses are retried up to 3 times | [ ] |
53+
| 3.3.3.1 | Retries utilize an exponential backoff with jitter | [ ] |
54+
| 3.3.3.1 | Will recover after a sustained Timber service outage | [x] |
55+
| 3.3.3.2 | `Authorization` header is properly set | [x] |
56+
| 3.3.3.3 | Payload is `UTF-8` encoded | [x] |
57+
| 3.3.3.4 | Payload uses a supported content type | [x] |
58+
| 3.3.3.4 | The `Content-Type` header is properly set | [x] |
59+
| 3.3.3.5 | The `User-Agent` header is properly set | [x] |
60+
61+
## v1.1.0 - Structured Logging
62+
63+
| Sec | Requirement | |
64+
|--------:|:---------------------------------------------------------------------------|:---:|
65+
| **3** | **Logging Pipeline** | |
66+
| 3.1 | Additionally integrates with popular logging libraries | [x] |
67+
| 3.2.3 | Accepts structured data as the message | N/A |
68+
| 3.2.4 | Accepts supplemental structured data | [x] |
69+
| 3.3.1 | Defines a log event data structure | [x] |
70+
| 3.3.1.1 | The JSON encoded log event properly adopts a versioned Timber event schema | [x] |
71+
| 3.3.1.2 | Normalizes strings into Timber events | [x] |
72+
| 3.3.1.3 | Normalizes structured data into Timber events | [x] |
73+
| 3.3.2 | Provides an IO device formatter that preserves structured data | [x] |
74+
| 3.3.2 | IO device formatter uses the proper `@metadata` delimiter | [x] |
75+
| 3.3.2 | New line characters within the metadata are escaped | [x] |
76+
| 3.3.2 | Formats logs before being sent to the IO device | [x] |
77+
78+
## v1.2.0 - Events
79+
80+
| Sec | Requirement | |
81+
|--------:|:-----------------------------------------------------------------|:---:|
82+
| **3** | **Logging Pipeline** | |
83+
| 3.2.5 | Accepts events as structured data | [x] |
84+
| 3.3.1.3 | Normalizes Timber official events | [x] |
85+
| 3.3.1.4 | Normalizes custom events | [x] |
86+
| **4** | **Events** | |
87+
| 4.1 | Defines a base event data structure | [x] |
88+
| 4.2 | Defines events for all Timber official events | [x] |
89+
| 4.3 | Allows users to define custom events by extending the base event | [x] |
90+
91+
## v1.3.0 - Context
92+
93+
| Sec | Requirement | |
94+
|--------:|:--------------------------------------------------------|:---:|
95+
| **3** | **Logging Pipeline** | |
96+
| 3.3.1.4 | Injects context into the final log event | [x] |
97+
| **5** | **Context** | |
98+
| 5.4 | Context data structure is a map or hash like structure | [x] |
99+
| 5.5 | Context can be JSON encoded | [x] |
100+
| 5.6 | Adding context performs a shallow merge | [x] |
101+
| 5.7 | Context can be removed on a key basis | [ ] |
102+
| 5.8 | Context can be added and removed within a lexical scope | N/A |
103+
| 5.9.1 | Runtime context is captured by default (if possible) | [x] |
104+
| 5.9.2 | Host context is captured by default | [x] |
105+
| 5.9.3 | EC2 context is captured by default | [ ] |
106+
| 5.9.4 | Heroku context is captured by default | [ ] |
107+
108+
[timber_library_specification]: https://github.com/timberio/library-specification

CHANGELOG.md

+29-146
Original file line numberDiff line numberDiff line change
@@ -1,156 +1,39 @@
11
# Changelog
22

3-
All notable changes to this project will be documented in this file.
3+
This covers changes for versions 3.0 and higher. The changelog for 2.x releases
4+
can be found in the [v2.x
5+
branch](https://github.com/timberio/timber-elixir/blob/v2.x/CHANGELOG.md).
46

57
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6-
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
8+
and this project adheres to [Semantic
9+
Versioning](http://semver.org/spec/v2.0.0.html).
710

811
## [Unreleased]
912

10-
## [2.8.3] - 2018-08-13
13+
## [3.0.0] - 2018-12-20
1114

1215
### Changed
1316

14-
- The system hostname is now cached after it is fetched the first time.
15-
Previously, the hostname was fetched every time a log line was formatted for
16-
output (whether by formatting occured in the console formatter or during
17-
HTTP transport). This reduces the overhead caused by fetching the hostname.
18-
19-
## [2.8.2] - 2018-07-01
20-
21-
### Changed
22-
23-
- Allow `~> 2.0` for the `:msgpax` dependency.
24-
25-
## [2.8.1] - 2018-06-07
26-
27-
### Added
28-
29-
- Add support for inline context via the `:context` `Logger` metadata key.
30-
- Add `Timber.remove_context_key` for removing an individual keys off of context structures.
31-
32-
### Changed
33-
34-
- Relax the `:plug` dependency to allow for more plug versions.
35-
36-
## [2.8.0] - 2018-04-16
37-
38-
### Added
39-
40-
- `Timber.Integrations.ErrorLogger` allows you to include a new OTP
41-
`:error\_logger` handler to better maintain the structure of errors and
42-
stacktraces. It also collapses many cases of multi-line logs into a single
43-
line.
44-
45-
### Fixed
46-
47-
- Fixed Logger metadata to use the pid from the Logger event and fall back
48-
to `self()`.
49-
50-
- Fix an issue with the regular expression that detects the Router during
51-
installation.
52-
53-
- Fix an issue with being able to skip files during installation when multiple
54-
files match.
55-
56-
## [2.7.0] - 2018-03-22
57-
58-
### Added
59-
60-
- `Timber.add_context/2` now allows you to set context either locally or globally;
61-
`Timber.add_context/1` will default to storing the context locally (consistent
62-
with previous versions of the library)
63-
- The `Timber.LocalContext` now manages setting and updating the Timber context
64-
maintained in the Elixir Logger metadata. This replaces the `Timber.CurrentContext`
65-
module. `Timber.LocalContext.get/0` should be used where
66-
`Timber.CurrentContext.load/0` was used before, and `Timber.LocalContext.put/1`
67-
should be used where `Timber.CurrentContext.save/1` was used.
68-
69-
### Changed
70-
71-
- `Timber.LogEntry.new/4` will fetch the global context and merge it into the
72-
local metadata context. The local context will override the global context
73-
based on the rules for `Timber.Context.merge/2`
74-
- Phoenix Channels integration will now accept _any_ channel message payload.
75-
(Previously, non-map types were dropped and replaced with an empty map.)
76-
77-
### Deprecated
78-
79-
- `Timber.CurrentContext` has been deprecated in favor of `Timber.LocalContext`;
80-
the new name better reflects the purpose of the module. Use of
81-
`Timber.CurrentContext` will still be supported for the lifetime of v2
82-
83-
### Fixed
84-
85-
- Phoenix Channels integration with Phoneix 1.3+ will no longer fail if the
86-
payload of a channel message is a list
87-
88-
## [2.6.1] - 2017-10-02
89-
90-
### Fixed
91-
92-
- Fixed an error where `Timber.Integrations.PhoenixInstrumenter` would fail
93-
on versions of Phoenix prior to 1.3 that do not pass a `:conn` key with the
94-
`phoenix_controller_render/3` `:start` event.
95-
96-
- Fixed `Timber.Integrations.PhoenixInstrumenter` did not define a
97-
fall-through for `phoenix_controller_render/3` during the `:start` event for
98-
when the third-parameter is in a different format than expected.
99-
100-
- Fixed `Timber.Integrations.PhoenixInstrumenter` did not define a
101-
fall-through when the instrumentation system sends a default state value for
102-
the `:stop` event on `phoenix_controller_render/3`.
103-
104-
## [2.6.0] - 2017-09-28
105-
106-
### Changed
107-
108-
- Logger backends now conform to the `:gen_event` behaviour rather than calling
109-
the `GenEvent.__using__/1` macro which is deprecated in Elixir 1.5.0 and
110-
above. The change is backwards compatible since `:gen_event` is provided by
111-
all supported versions of Erlang.
112-
113-
## [2.5.6] - 2017-09-28
114-
115-
### Fixed
116-
117-
- Fixed an error where `Timber.Integrations.PhoenixInstrumenter` would cause
118-
an error during blacklist checks if the blacklist had not been set up.
119-
120-
- Fixed an error where `Timber.Integrations.PhoenixInstrumenter` would fail on render
121-
events for `conn` structs that did not have a controller or action set. For
122-
example, when a `conn` did not match listed routes, a `404.html` template
123-
would be rendered that did not have a controller or action. The render event
124-
would still be triggered though.
125-
126-
## [2.5.5] - 2017-09-21
127-
128-
### Fixed
129-
130-
- `Timber.Events.HTTPRepsonseEvent` no longer enforces the `:time_ms` key on
131-
the struct. This brings it in line with the specification
132-
133-
## [2.5.4] - 2017-09-18
134-
135-
### Fixed
136-
137-
- Fixed a bug within the installer where HTTP log delivery was being used on platforms that
138-
should use STDOUT / :console.
139-
140-
### Added
141-
142-
- Support for blacklisting controller actions with
143-
`Timber.Integrations.PhoenixInstrumenter`. This will suppress log lines
144-
from being written for any controller/action pair.
145-
146-
[Unreleased]: https://github.com/timberio/timber-elixir/compare/v2.8.3...HEAD
147-
[2.8.3]: https://github.com/timberio/timber-elixir/compare/v2.8.2...v2.8.3
148-
[2.8.2]: https://github.com/timberio/timber-elixir/compare/v2.8.1...v2.8.2
149-
[2.8.1]: https://github.com/timberio/timber-elixir/compare/v2.8.0...v2.8.1
150-
[2.8.0]: https://github.com/timberio/timber-elixir/compare/v2.7.0...v2.8.0
151-
[2.7.0]: https://github.com/timberio/timber-elixir/compare/v2.6.1...v2.7.0
152-
[2.6.1]: https://github.com/timberio/timber-elixir/compare/v2.6.0...v2.6.1
153-
[2.6.0]: https://github.com/timberio/timber-elixir/compare/v2.5.6...v2.6.0
154-
[2.5.6]: https://github.com/timberio/timber-elixir/compare/v2.5.5...v2.5.6
155-
[2.5.5]: https://github.com/timberio/timber-elixir/compare/v2.5.4...v2.5.5
156-
[2.5.4]: https://github.com/timberio/timber-elixir/compare/v2.5.3...v2.5.4
17+
- [Jason](https://hex.pm/packages/jason) is now used for JSON encoding. The
18+
JSON library can no longer be injected via configuration.
19+
- [`msgpax`](https://hex.pm/packages/msgpax) 1.x is no longer supported
20+
- Logs are now sent in batches of 1000 instead of 5000 to comply with the
21+
Timber library specification
22+
- `Timber.LoggerBackends.HTTP.TimberAPIKeyInvalid` is now `Timber.InvalidAPIKeyError`
23+
24+
### Removed
25+
26+
- Removed support for Elixir 1.3 and lower
27+
- Removed integration with Phoenix; use the
28+
[`:timber_phoenix`](https://hex.pm/packages/timber_phoenix) package instead
29+
- Removed integration with Plug; use the
30+
[`:timber_plug`](https://hex.pm/packages/timber_plug) package instead
31+
- Removed integration with Ecto; use the
32+
[`:timber_ecto`](https://hex.pm/packages/timber_ecto) package instead
33+
- Removed integration with ExAws
34+
- Removed integration with `:error_logger`; use the
35+
[`:timber_exceptions`](https://hex.pm/packages/timber_exceptions) package
36+
instead
37+
- Removed the installer (`mix timber.install`); manual installation is now
38+
expected
39+
- Removed the test event Mix task

0 commit comments

Comments
 (0)