Commit Graph

63 Commits

Author SHA1 Message Date
Jacob Hoffman-Andrews cb06fe8e13
log: Remove trailing newlines and escape internal newlines. (#4925)
Fixes #4914.
2020-07-06 14:17:23 -07:00
Jacob Hoffman-Andrews 75024c3ec1
Replace clock.Default() with clock.New() (#4761)
clock.Default is deprecated:
https://godoc.org/github.com/jmhodges/clock#Default
2020-04-08 17:23:43 -07:00
Jacob Hoffman-Andrews 3a1a08a10b
Remove unused code. (#4722)
Found by staticcheck.
2020-03-27 11:55:42 -07:00
Daniel McCarney eb4445be6c
log: panic if bothWriter write to stdout errs. (#4491)
If we can't write to stdout we prefer to panic immediately rather than
potentially lose logs we capture from redirecting stdout as a syslog backup.

A unit test is included to verify the panic behaviour. Prior to the `log` diff
in this branch the test failed because the non-nil `err` result from
`fmt.Printf` was being away:

```
=== RUN   TestStdoutFailure
=== PAUSE TestStdoutFailure
=== CONT  TestStdoutFailure
FAIL	github.com/letsencrypt/boulder/log	0.011s
FAIL
```

After the `log` package diff in this branch is applied the test passes.

I additionally tested this end-to-end by redirecting stdout to a full
filesystem volume mounted into the Boulder docker image. It provoked the
expected panic when a component tried to write to stdout and the filesystem was
full.
2019-10-18 13:53:00 -04:00
Roland Bracewell Shoemaker f32fdc4639
Include a CRC32-IEEE checksum in log lines (#4478)
Adds a CRC32-IEEE checksum to our log lines. At most this adds 8 bytes per line, and at least adds 2 bytes. Given this a relatively minor change I haven't bothered flagging it, although if we have anything in place that assumes the current structure of log lines we may want to add a flag in order to prevent immediate breakage before things can be altered.

Fixes #4474.
2019-10-14 13:57:43 -07:00
Joel Sing 8ebdfc60b6 Provide formatting logger functions. (#3699)
A very large number of the logger calls are of the form log.Function(fmt.Sprintf(...)).
Rather than sprinkling fmt.Sprintf at every logger call site, provide formatting versions
of the logger functions and call these directly with the format and arguments.

While here remove some unnecessary trailing newlines and calls to String/Error.
2018-05-10 11:06:29 -07:00
Jacob Hoffman-Andrews 9003dd4522 Improve test-tools. (#3481)
Use `t.Helper` and `t.Fatalf` instead of our own versions.

Remove some unused or single-user helpers.

Make the output of `AssetUnmarshaledEquals` clearer by showing one line per field.
2018-02-27 10:19:24 -05:00
Roland Bracewell Shoemaker 04394d1b76 Add newline when printing to STDERR (#2919)
In `log/log.go` when we fail to write to syslog we log the message to STDERR but without a newline. This causes all of the STDERR logs (when we reconnect to syslog) to be delivered where they go to be on a single line which causes some debugging pain.
2017-07-29 10:27:45 -07:00
Jacob Hoffman-Andrews b17b5c72a6 Remove statsd from Boulder (#2752)
This removes the config and code to output to statsd.

- Change `cmd.StatsAndLogging` to output a `Scope`, not a `Statter`.
- Remove the prefixing of component name (e.g. "VA") in front of stats; this was stripped by `autoProm` but now no longer needs to be.
- Delete vendored statsd client.
- Delete `MockStatter` (generated by gomock) and `mocks.Statter` (hand generated) in favor of mocking `metrics.Scope`, which is the interface we now use everywhere.
- Remove a few unused methods on `metrics.Scope`, and update its generated mock.
- Refactor `autoProm` and add `autoRegisterer`, which can be included in a `metrics.Scope`, avoiding global state. `autoProm` now registers everything with the `prometheus.Registerer` it is given.
- Change va_test.go's `setup()` to not return a stats object; instead the individual tests that care about stats override `va.stats` directly.

Fixes #2639, #2733.
2017-05-15 10:19:54 -04:00
Josh Soref 8adf9d41cf Spelling (#2500)
Various spelling fixes.
2017-01-16 10:44:52 -05:00
Blake Griffith 344a312905 Remove audit comments -- closes #2129 (#2139)
Closes #2129

* Remove audit comments.
* Nuke doc/requirements/*
2016-08-25 18:23:42 -07:00
Ben Irving 1336c42813 Replace all log.Err calls with log.AuditErr (#1891)
* remove calls to log.Err()
* go fmt
* remove more occurrences
* change AuditErr argument to string and replace occurrences
2016-06-06 16:27:16 -04:00
Roland Bracewell Shoemaker 54573b36ba Remove all stray copyright headers and appends the initial line to LICENSE.txt (#1853) 2016-05-31 12:32:04 -07:00
Ben Irving fc36faa744 Add test 2016-05-26 09:32:32 -07:00
Ben Irving 555df262f7 Lower sysloglevel in test configs; remove prefix from if block 2016-05-26 09:32:32 -07:00
Ben Irving d88cce5c72 Add config option to lower syslog level 2016-05-26 09:32:32 -07:00
Jacob Hoffman-Andrews e6c17e1717 Switch to new vendor style (#1747)
* Switch to new vendor style.

* Fix metrics generate command.

* Fix miekg/dns types_generate.

* Use generated copies of files.

* Update miekg to latest.

Fixes a problem with `go generate`.

* Set GO15VENDOREXPERIMENT.

* Build in letsencrypt/boulder.

* fix travis more.

* Exclude vendor instead of godeps.

* Replace some ...

* Fix unformatted cmd

* Fix errcheck for vendorexp

* Add GO15VENDOREXPERIMENT to Makefile.

* Temp disable errcheck.

* Restore master fetch.

* Restore errcheck.

* Build with 1.6 also.

* Match statsd.*"

* Skip errcheck unles Go1.6.

* Add other ignorepkg.

* Fix errcheck.

* move errcheck

* Remove go1.6 requirement.

* Put godep-restore with errcheck.

* Remove go1.6 dep.

* Revert master fetch revert.

* Remove -r flag from godep save.

* Set GO15VENDOREXPERIMENT in Dockerfile and remove _worskpace.

* Fix Godep version.
2016-04-18 12:51:36 -07:00
Kane York 25b45a45ec Errcheck errors fixed (#1677)
* Fix all errcheck errors
* Add errcheck to test.sh
* Add a new sa.Rollback method to make handling errors in rollbacks easier.
This also causes a behavior change in the VA. If a HTTP connection is
abruptly closed after serving the headers for a non-200 response, the
reported error will be the read failure instead of the non-200.
2016-04-12 16:54:01 -07:00
Jacob Hoffman-Andrews ecc04e8e61 Refactor log package (#1717)
- Remove error signatures from log methods. This means fewer places where errcheck will show ignored errors.
- Pull in latest cfssl to be compatible with errorless log messages.
- Reduce the number of message priorities we support to just those we actually use.
- AuditNotice -> AuditInfo
- Remove InfoObject (only one use, switched to Info)
- Remove EmergencyExit and related functions in favor of panic
- Remove SyslogWriter / AuditLogger separate types in favor of a single interface, Logger, that has all the logging methods on it.
- Merge mock log into logger. This allows us to unexport the internals but still override them in the mock.
- Shorten names to be compatible with Go style: New, Set, Get, Logger, NewMock, etc.
- Use a shorter log format for stdout logs.
- Remove "... Starting" log messages. We have better information in the "Versions" message logged at startup.

Motivation: The AuditLogger / SyslogWriter distinction was confusing and exposed internals only necessary for tests. Some components accepted one type and some accepted the other. This made it hard to consistently use mock loggers in tests. Also, the unnecessarily fat interface for AuditLogger made it hard to meaningfully mock out.
2016-04-08 16:12:20 -07:00
Jacob Hoffman-Andrews 8c915f50f6 Change panics in audit logger to log.Fatalf. (#1695)
* Change panics in audit logger to log.Fatalf.

These errors can happen if the syslog apparatus is unavailable, so are not that
out of the ordinary. log.Fatalf produces less noise and makes it easier to see
what's wrong.

* Fix imports.
2016-04-07 13:47:12 -07:00
Roland Bracewell Shoemaker 32e9e44906 Remove activity-monitor from the tree
* Axe boulder-am
* Also remove the analysis subpackage and references to it, and remove routingKey from rpc/connection.go

https://github.com/letsencrypt/boulder/pull/1682
2016-04-04 12:19:17 -07:00
Jacob Hoffman-Andrews 659e4f0b94 Remove some unnecessary AuditPanics.
This is now done in cmd/shell.go.
2016-03-27 19:09:01 -07:00
Kevin Burke 4dde762318 Make the AuditLogger example show up in the docs
`godoc` associates the docs with the function or type listed after
the word "Example"; in this case "Errors" doesn't match anything in
github.com/letsencrypt/boulder/log, so the example doesn't appear in the
generated godoc.

Changes the function name to ExampleAuditLogger so it shows up under the
AuditLogger type.

Here's a screenshot:
https://monosnap.com/file/iXHqZHlnAjXnXPkAWUR5J1jMggOHLQ.png
2016-03-26 10:22:42 -07:00
Jacob Hoffman-Andrews 5a0f8691d5 Add colorful stdout logging.
This won't affect prod, where we use syslog. But for dev and test, where we log
to stdout, the colors may help us find errors and warnings in the logs.

This also adds the log level as an explicit part of the stdout logging.
2016-03-23 14:20:53 -07:00
Kane York 1f44abcba7 Fix tests for AuditNotice, add AuditErr to tests 2016-02-25 11:32:21 -08:00
Kane York db8bea7b05 Specify severity of all log.Audit calls
Fixes #1534
2016-02-25 10:55:01 -08:00
Alex Gaynor cbeffe96a6 Fixed a bunch of typos 2016-01-04 18:39:34 -05:00
Jacob Hoffman-Andrews 2fc0f3143e Improve logging.
Consolidate initialization of stats and logging from each main.go into cmd
package.

Define a new config parameter, `StdoutLevel`, that determines the maximum log
level that will be printed to stdout. It can be set to 6 to inhibit debug
messages, or 0 to print only emergency messages, or -1 to print no messages at
all.

Remove the existing config parameter `Tag`. Instead, choose the tag from the
basename of the currently running process. Previously all Boulder log messages
had the tag "boulder", but now they will be differentiated by process, like
"boulder-wfe".

Shorten the date format used in stdout logging, and add the current binary's
basename.

Consolidate setup function in audit-logger_test.go.

Note: Most CLI binaries now get their stats and logging from the parameters of
Action. However, a few of our binaries don't use our custom AppShell, and
instead use codegangsta/cli directly. For those binaries, we export the new
StatsAndLogging method from cmd.

Fixes https://github.com/letsencrypt/boulder/issues/852
2015-11-11 16:52:42 -08:00
Jeff Hodges 99e85bcae7 correct initializeAuditLogger comment 2015-07-31 10:11:37 -07:00
Jeff Hodges 7e9182c2ba panic on errors in initializeAuditLogger
Found when poking at the new containerized Travis CI build with
@rolandshoemaker. This was causing strange panics far away from here
when code would try to log audits when there was no syslog available.
2015-07-31 03:01:21 -07:00
Jeff Hodges 8975601d5e correct bodyStr->body 2015-07-23 17:41:15 -07:00
Tom Clegg 0e72f95660 Add mock for syslog. 2015-07-19 05:44:56 -04:00
Roland Shoemaker 036c80703b Remove duplication 2015-06-23 19:16:44 +01:00
Roland Shoemaker 8d379ab499 Use standard JSON format in logger 2015-06-23 19:10:09 +01:00
Roland Shoemaker 8183ce5312 Fix typo 2015-06-21 14:08:29 -07:00
Roland Shoemaker 617df9f937 Merge branch 'master' into wfe-logging 2015-06-20 16:05:51 -07:00
J.C. Jones ae9a8a38fa Improve audit logging on panic conditions:
- Audit log the error
- Audit log the current frame
- Warning log the other frames (up to 8k)
2015-06-20 10:53:10 -07:00
Roland Shoemaker f228ac41f5 Add connection logging to the WFE 2015-06-19 16:47:54 -07:00
J.C. Jones 2d92b1f348 Issue #286: Audit Logs not Transmitted
- Add tests for transmission of each log level
- Add default level for `logAtLevel` to catch programming errors
- Transmit things logged at `Logging.Notice`
2015-06-01 22:43:35 -07:00
J.C. Jones af0f8446eb Issue #202, Periodic OCSP Signer Tool
- Move dbMap construction and type converter into individual files in the sa package.
- Add DB configuration for the OCSP tool to the boulder config:
  - left to the user if they want to use different boulder-config.json files
    for different purposes.
- Added updater to Makefile
- Fix trailing ',' in the Boulder config, add more panic logging
- Ignore .pem files produced by the integration test
- Change RPC to use per-instance named reply-to queues.
- Finish OCSP Updater logic
- Rework RPC for OCSP to use a transfer object (due to serialization problems of x509.Certificate)
2015-05-27 22:01:29 -07:00
J.C. Jones f15da06af7 Issue #238 - MySql column width too narrow
- Added SQL debug logging (SA option: "SQLDebug")
- Added timestamps to the log prints to stdout
- Ignore *.pem in test/js
- Modified start.sh to support environment overrides for BOULDER_CONFIG, like the AMQP mode
- Changed boulder-test-config to open the server on the loopback device, so as to not cause firewall prompts on each integration test run for those of us being restrictive
- Renamed "key" column to "jwk" in DB, to avoid keyword conflict
- Set MaxLength on "jwk" column to 512
2015-05-27 12:12:41 -07:00
J.C. Jones 1c9837ddf8 Audit all Challenges (success/failure) in VA for Issue #204
- Don't ignore entropy underruns in challenges.go
- Correct identity crisis in Policy Authority; hopefully it will remember.
- Add a method `AuditObject` in audit-logger and convert RA/VA to use it
- Fix json typo in registration-authority that caused empty audit logs
- Fix vet issue in WFE where RegID was being printed as a 32-bit int instead of 64-bit
- Unfix the issue in WFE where RegID isn't right, per PR #215
2015-05-21 13:58:40 -07:00
J.C. Jones 42302541bd Run `go fmt` for PR #186 2015-05-18 18:44:38 -07:00
J.C. Jones d2be0dcb95 Review updates 2015-05-18 18:24:37 -07:00
Richard Barnes c3b312118e Add audit logging
- Auditing for general errors in executables
- Auditing for improper messages received by WFE
- Automatic audit wlogging of software errors
- Audit logging for mis-routed messages
- Audit logging for certificate requests
- Auditing for improper messages received by WFE
- Add audit events table
- Expect more details in TestRegistration in web-front-end_test.go
- Remove "extra" debug details from web-front-end.go per Issue #174
- Improve test coverage of web-front-end.go
- WFE audit updates for revocation support rebase
- Add audit messages to RPC for Improper Messages and Error Conditions
- Also note misrouted messages
2015-05-18 18:23:08 -07:00
Peter Eckersley f00848e115 Hypothetical RNG failure handling 2015-05-01 22:03:59 -07:00
J.C. Jones cead23df00 Updates per jsha's review 2015-05-01 21:50:07 -07:00
J.C. Jones e828c61818 Add singleton semantics to Audit Logger, per Issue #135
- Update tests to use the singleton logger
- Update commands to set the audit logger singleton
- Formatting updates to the tests (go fmt)
2015-05-01 21:48:24 -07:00
Jacob Hoffman-Andrews dd58bdcaa1 Merge branch 'master' into schema-updates
Conflicts:
	sa/storage-authority.go
2015-04-27 17:21:31 -07:00
Jacob Hoffman-Andrews 1743fb2edb Fix stats for log.Notice. 2015-04-27 15:50:31 -07:00