summaryrefslogtreecommitdiff
path: root/crates/arti/src/logging.rs
Commit message (Collapse)AuthorAgeFilesLines
* Match previous backtrace formattingRobin Leander Schröder2024-08-081-2/+2
| | | | | std::backtrace::Backtrace's Display looks the same as backtrace_rs::Backtrace's Debug
* Use std::backtrace instead of backtrace crateRobin Leander Schröder2024-08-011-3/+1
| | | | | Removes resolve_backtraces from rtmock since it is no longer needed as stdlib's backtraces automatically lazily resolve without needing a &mut.
* arti: Don't output ANSI escape codes when logging to file.Gabriela Moldovan2024-02-221-0/+1
| | | | Closes #1298
* educe: Use std's default for enums where default variant is unitIan Jackson2024-02-121-4/+2
| | | | | | | | | | | | | Since Rust 1.66, std's default works properly for enums, provided that the default variant is a unit. Review all uses of `#[educe(default)]` on enums and replace them with std where possible, which is most of them. In 1.66 and later, std's `#[derive(Default)]` doesn't infer any generic bounds on the derived impl, where it's an enum - since the unit variant can always be constructed. So this change doesn't add any generic bounds and is not API-visible.
* Throughout: Use *_report!() macros for reporting Errors.Nick Mathewson2023-07-071-3/+3
| | | | | | | | | | | | | | | I identified the cases to replace by searching for the string `.report()`. There are a few that I didn't change: * A couple of cases that used anyhow::Error, * One case that reported two Errors. * Two cases in `tor_hsclient::err` that just did `error!("Bug: {}")`. I have also not audited the cases in `tor-hsclient` where we're using `tor_error::Report` manually. Nonetheless, closes #949.
* Merge branch 'log_precision' into 'main'Nick Mathewson2023-07-061-4/+25
|\ | | | | | | | | | | | | arti: Add a `logging.time_granularity` option with 1s default. Closes #551 See merge request tpo/core/arti!1376
| * arti: Add a `logging.time_granularity` option with 1s default.Nick Mathewson2023-07-061-4/+25
| | | | | | | | | | | | | | This lets us provide less information in our logs: in particular, it lets us avoid logging with microsecond precision. Closes #551.
* | arti: Note possibility for future use of other tracing panic providerNick Mathewson2023-07-061-0/+5
| |
* | arti: On panic, avoid allocation even more.Nick Mathewson2023-07-061-7/+5
| | | | | | | | | | | | | | | | | | | | The original version of our panic handler would allocate a string for the panic `Location`. But if we're panicking we'd like to keep allocations to a minimum: so instead format the `Location` conditionally. This also drops a useless `std::borrow::Cow`. (The possibility of a "Don't have a `Cow`" commit message was considered and rejected.)
* | Add TODO comments about possibly migrating away from the backtrace crate.Nick Mathewson2023-07-051-1/+2
| |
* | arti: Install a panic hook that sends messages to `tracing`Nick Mathewson2023-07-051-0/+31
|/ | | | | | | (Also leaves installed the default handler that sends messages to stderr.) Closes #921.
* Use ErrorReport/Report for errors in warn! in artiIan Jackson2023-01-301-1/+2
|
* Enforce SafeLogging on the console.Nick Mathewson2022-09-261-30/+10
| | | | | | | | | | | | Previously we always assumed that the console was ephemeral, and so we disabled safe logging. But the console can be piped to journald. And even if we enforce isatty there's no guarantee that the user isn't using some kind of terminal that logs to disk or something. Best just to enable SafeLogging unconditionally. I've added a note about where and how we might re-enable this. Closes #553.
* Mark a few APIs as experimental in docs.Nick Mathewson2022-08-301-0/+1
| | | | | | | | For example, see https://tpo.pages.torproject.net/core/doc/rust/arti/fn.run.html : this isn't labeled as `experimental-api`, but it should be. These APIs were found by poking around in the `arti` crate.
* arti: Raise the default console log severity to "info"Nick Mathewson2022-08-251-1/+1
| | | | | Previously we logged at "debug", but that's not meant to user-facing.
* arti: Move most public APIs behind `experimental-api`.Nick Mathewson2022-08-111-2/+4
| | | | | | | | | | | | | | | | | The remaining unconditionally public APIs are those related to our configuration objects, and the main_main() API. The rationale for making main_main() public is to have an actual entry point. The rationale for making the config APIs public is: 1. We really do intend for others to be able to read our configuration files using this API. 2. The structure of our configuration files is already part of our interface. Closes #530.
* impl_standard_builder: Use for arti::logging::LogfileConfigIan Jackson2022-06-161-7/+2
|
* arti: logging config: Replace a manual Debug implIan Jackson2022-06-161-7/+4
|
* config: Do not strip_option for journald (and in future)Ian Jackson2022-06-101-1/+1
| | | | | As per point 1 in https://gitlab.torproject.org/tpo/core/arti/-/issues/488
* config: Provide tor_config::resolve_option and resolve journaldIan Jackson2022-05-301-1/+4
| | | | | | | | | | | | | | Canonicalise the `logging.journald` setting in the validated configuration. Now it will never be `Some("")`, even if that is what was written in the config file. This allows us to write `journald = ""` in the example configuration. (Without the canonicalisation the default builder produces `None` and the example would produce `Some("")`, which are semantically identical but fail the test.) See https://gitlab.torproject.org/tpo/core/arti/-/issues/488 for some background.
* Apply fs-mistrust to logfile directories.Nick Mathewson2022-05-241-5/+15
|
* impl_standard_builder: Have it generate FooConfig::builderIan Jackson2022-05-121-7/+0
| | | | | This deletes many handcoded impls. It also generates lots of impls that we previously didn't have.
* Rename impl_standard_builder from impl_default_via_builderIan Jackson2022-05-121-2/+2
| | | | | | | | | | | | I have Plans for this macro. In particular: * I have a wip branch which tests that the Builder can be deserialised from an empty config (ie, that config reading of a config with a blank section for this item works). * I think we should autogenerate $Config::builder(), and promote that, rather than $ConfigBuilder::default(). This macro could do that.
* config: Replace more handwritten impl DefaultIan Jackson2022-05-121-6/+2
|
* Disable safe-logging when logging to console.Nick Mathewson2022-05-061-1/+30
|
* arti: add support for safe-logging configurationNick Mathewson2022-05-061-2/+33
| | | | | | Here we add a config option to disable safe logging, and ensure that safe logging is disabled when we are formatting an error message on exit (since we assume it's safe to write sensitive info to stderr.)
* config derive attrs: Make builders serde, and validated structs notIan Jackson2022-05-051-10/+5
| | | | | | | | | | | | | | | * Builders additionally derive: Debug, Serialize, Deserialize. * Validated structs no longer derive: Serialize, Deserialize and all related attributes deleted. * As a consequence, all the `#[serde(deny_unknown_fields)]` are gone. That means that right now unknown fields are totally ignored. This is good for compatibility but poor for useability. Doing something better here is arti#417, in progress. * As a consequence, delete tor_dirmgr::retry::default_parallelism. (The default value was already duplicated into a builder attr.)
* Make LogRotation SerializeIan Jackson2022-05-051-1/+1
| | | | We want to be able to serialise as well as deserialise configurations.
* Change builder list APIIan Jackson2022-05-041-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | The new API is (roughly) as discussed in https://gitlab.torproject.org/tpo/core/arti/-/issues/451 This is quite a large commit and it is not convenient to split it up. It contains the following changes: * Redo the list builder and accessor macros implemnetation, including docs and tests. * Change uses of define_list_config_builder. In each case: - Move the docs about the default value to the containing field. - Remove the other docs (which were just recapitulations, and are now not needed since the ListBuilder is no longer public). - Rewmove or replace `pub` in the define_list_builder_helper call, so that the builder is no longer public. - Change the main macro call site to use define_list_builder_helper. - Add a call to define_list_builder_accessors. * Make the module `list_builder` pub so that we have somewhere to put the overview documentation. * Consequential changes: - Change `outer.inner().replace(X)` to `outer.set_inner(X)` - Consequential changes to imports (`use` statements).
* Document defaults for all the config listsIan Jackson2022-04-251-1/+3
| | | | | | | And add an imprecation in define_list_config_builder's doc comment do do so in future for other invocations of the macro. Add add the missing full stops.
* Use better syntax for doc comment attributeIan Jackson2022-04-251-3/+1
| | | | | As per https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/471#note_2798020
* Introduce define_list_config_builder macroIan Jackson2022-04-251-46/+9
| | | | | | This replaces two almost-identical sets of structs and impls. More are on the way, as per https://gitlab.torproject.org/tpo/core/arti/-/issues/447
* logging: Drop a pointless .within() callIan Jackson2022-04-251-2/+1
| | | | | | | | | | Since "logfiles: Introduce LogfileListConfigBuilder", this code is in LogfileListConfigBuilder::build(), which is called by derive_builder's generated LoggingConfig::build(), and which will add a file context itself due to the `sub_builder` feature. So this is otiose. And, we are about to replace this whole thing with macro_rules-generated code (which won't do this).
* logfiles: Introduce LogfileListConfigBuilderIan Jackson2022-04-221-16/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | In https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697 we decided not to do this. However, having looked again at the way the FallbackList works, I think there is a lot of value in making these two things (and anything else like them[1]) as similar as possible. [1] At least PreemptiveCircuitConfig.initial_predicted_ports and NetworkConfig.authorities need the same treatment, and perhaps also GuardUsage.restrictions (although there is no GuardRestrictionBuilder). In the irc discussion I imagined `LogfilesConfigBuilder` as opposed to `LogfileConfigBuilder` (differing only in the `s`) which would be bad, but we can use `List` instead. We do *not* need to abstract away the validated version of the config. Providing a type alias helps the derive_builder sub_builder DTRT without needing special overrides. I have split this commit so that we can drop it, if we conclude it's not wanted.
* logfiles: Adjust LoggingConfigBuilder::file and impl DeserializeIan Jackson2022-04-221-1/+54
| | | | | | | | | Change LoggingConfigBuilder to contain Vec<LogfileConfigBuilder>, not Option<Vec<LogfileConfig>>. That makes it sane to Deserialize. Replace LoggingConfigBuilder's file(Vec<>) setter with the methods discussed in https://gitlab.torproject.org/tpo/core/arti/-/merge_requests/462#note_2797697
* logfiles Rename LogfileConfig::file to filesIan Jackson2022-04-221-4/+4
| | | | | It's a plural, and that fact is going to be exposed via serde, if it isn't already.
* Tidy up filt_from_opt_strIan Jackson2022-03-211-4/+3
| | | | This was clumsy. Now it is brought together it can be simplified.
* Abolish logging filter option accessorsIan Jackson2022-03-211-19/+7
| | | | | | | This de-duplicates the code that was in those accessors, and is now in filt_from_opt_str. Code motion and direct field access.
* Abolish easy accessors for logging configIan Jackson2022-03-211-26/+6
| | | | | | There are no longer needed, because the code that uses this configuration now lives in the same module as the configuration itself.
* Move logging configuration from arti_config::options to arti::loggingIan Jackson2022-03-211-1/+127
| | | | Code motion and import fixups.
* Rename arti::trace module to arti::loggingIan Jackson2022-03-211-0/+152
We are going to move LoggingConfig here. We should follow the already-public name IMO.