Commit ce12c08
Glyn Normington
Create a basic logging framework for the buildpack
This consists of a LoggerFactory class in a Diagnostics module. The
module also contains some common constants and a method to determine
the diagnostics directory
The LoggerFactory class manages a single instance of a subclass of the
standard Ruby Logger. In normal usage, only one logger should be
created:
logger = LoggerFactory.create_logger(app_dir)
The created logger can be retrieved from the LoggerFactory to avoid
having to pass it around:
logger = LoggerFactory.get_logger
Logging follows the style of the standard Ruby logger, which supports
both parameter and block forms:
logger.info('success')
logger.debug { "#{costly_method}" }
The logging level is configured by setting an environment variable
JBP_LOG_LEVEL to one of:
DEBUG | INFO | WARN | ERROR | FATAL
The default value if JBP_LOG_LEVEL is not set is configured in
config/logging.yml for consistency with other buildpack configuration
and in case someone wants to change it in a fork of the buildpack.
If JBP_LOG_LEVEL is set to an unrecognised value, the logging level is
set to DEBUG for safety (for instance, the user may have guessed that
TRACE is a valid value).
The logging level in JBP_LOG_LEVEL or config/logging.yml may be
specified using any mixture of upper and lower case.
Ruby's verbose and debug modes overrides the default logging level in
config/logging.yml to DEBUG. However, JBP_LOG_LEVEL still takes
priority.
Log entries are written to both app/.buildpack-
diagnostics/buildpack.log and $stderr.
Log entries are verbose and include full details of the caller such
as the full path of the Ruby program making the call.
Set $stderr to synchronous writing.
Introduce debug logging of stack traces.
Introduce a Buildpack.drive_buildpack_with_logger method to create a
logger and then yield a new Buildpack instance to the given block.
Make the Buildpack constructor private so it cannot be called from
elsewhere. This ensures that any Buildpack instance has a logger
available to it.
Create a logger in the spec helper to ensure that any class under test
which needs a logger will have one. The LoggerFactory tests override
this by re-creating the logger.
Issue warnings if the logger is re-created, but suppress these
warnings when testing the LoggerFactory and the Buildpack classes.
Remove the diagnostic directory from the buildpack context
Substitute the buildpack.log filename into killjava script rather
than hard-coding it.
Link to stackoverflow article on installing gems in support of
the RubyMine debugger.
[#52775343]1 parent 159d18b commit ce12c08
17 files changed
Lines changed: 756 additions & 259 deletions
File tree
- bin
- config
- docs
- lib/java_buildpack
- diagnostics
- jre
- util
- resources/openjdk/diagnostics
- spec
- java_buildpack
- diagnostics
- jre
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
51 | 52 | | |
52 | 53 | | |
53 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
54 | 59 | | |
55 | 60 | | |
56 | 61 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
37 | 32 | | |
38 | 33 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
| 26 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
0 commit comments