Vendor dependencies for 0.3.0 release

This commit is contained in:
2025-09-27 10:29:08 -05:00
parent 0c8d39d483
commit 82ab7f317b
26803 changed files with 16134934 additions and 0 deletions

View File

@@ -0,0 +1 @@
{"files":{"Cargo.toml":"32be97dc3d463c5dc75b5f75f774e44f614cc6b231acf4a1bd238b607811307a","LICENSE.md":"b36ff589a7b586161394980ac056831e3795e7390270c9be98bb2fa85829646d","README.md":"541e4e5e5c8ac8f5ee4982cc828ac6864bad3e6343e9d9ca324ae7824639df63","build.rs":"42a82fda8b44d18616c419a8f655232324ab890f02f573c8f74b5b8062c1ecd6","src/ffi.rs":"d9dde313263113f9883a1ef6eb1a3f71b8366199125284d9dd7489729fc0e861","src/lib.rs":"754821863e8c6618a5ef61ba31daa5bd44ad4708353ba849af0ecb13a89a2e67","src/logger.rs":"22bfdd24159427d8b700e9c482c7515e04b755f7899fb10aac1b8b03700a169f","src/stub.rs":"0fee8535f7f41a56207138af674e23747052191a64156aa97c1786c049f9f5f8","src/visitor.rs":"dabe10d3299b69a0c7ecf35bd1a3fd0a375e5f9bf009f8b22b0b4516212dff85","wrapper.c":"b9f2ad69cc523a0833a596fdd23ea4d08ad0a9930581da1ba393f619670b2f4e","wrapper.h":"d30b629646597e31b0655c70cdb78d5a784180493239134bcaedb3b694c0067a"},"package":"528bdd1f0e27b5dd9a4ededf154e824b0532731e4af73bb531de46276e0aab1e"}

72
vendor/tracing-oslog/Cargo.toml vendored Normal file
View File

@@ -0,0 +1,72 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
rust-version = "1.77"
name = "tracing-oslog"
version = "0.2.0"
authors = ["Lucy <lucy@absolucy.moe>"]
build = "build.rs"
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "A layer for tracing that outputs to the oslog on macOS/iOS"
documentation = "https://docs.rs/tracing-oslog"
readme = "README.md"
keywords = [
"tracing",
"oslog",
"os_log",
"macos",
"ios",
]
categories = [
"development-tools::debugging",
"development-tools::profiling",
"os::macos-apis",
]
license = "Zlib"
repository = "https://github.com/Absolucy/tracing-oslog"
[package.metadata.docs.rs]
targets = ["x86_64-apple-darwin"]
[lib]
name = "tracing_oslog"
path = "src/lib.rs"
[dependencies.cfg-if]
version = "1.0"
[dependencies.once_cell]
version = "1.8"
[dependencies.parking_lot]
version = "0.12"
[dependencies.tracing-core]
version = "0.1"
[dependencies.tracing-subscriber]
version = "0.3"
features = [
"std",
"registry",
]
default-features = false
[build-dependencies.bindgen]
version = "0.70"
[build-dependencies.cc]
version = "1.0"

22
vendor/tracing-oslog/LICENSE.md vendored Normal file
View File

@@ -0,0 +1,22 @@
The zlib/libpng License
=======================
Copyright (c) 2021 Lucy <lucy@absolucy.moe>
This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
this software.
Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.

52
vendor/tracing-oslog/README.md vendored Normal file
View File

@@ -0,0 +1,52 @@
# tracing_oslog
This is a [tracing](https://crates.io/crates/tracing) layer for the [Apple OS logging framework](https://developer.apple.com/documentation/os/logging).
[Activities](https://developer.apple.com/documentation/os/logging/collecting_log_messages_in_activities) are used to handle spans,
## Example
```rust
use tracing_oslog::OsLogger;
let collector = tracing_subscriber::registry()
.with(OsLogger::new("moe.absolucy.test", "default"));
tracing::subscriber::set_global_default(collector).expect("failed to set global subscriber");
let number_of_yaks = 3;
// this creates a new event, outside of any spans.
info!(number_of_yaks, "preparing to shave yaks");
let number_shaved = yak_shave::shave_all(number_of_yaks);
info!(
all_yaks_shaved = number_shaved == number_of_yaks,
"yak shaving completed."
);
```
## License
Copyright (c) 2021 Lucy <lucy@absolucy.moe>
This software is provided 'as-is', without any express or implied warranty. In
no event will the authors be held liable for any damages arising from the use of
this software.
Permission is granted to anyone to use this software for any purpose, including
commercial applications, and to alter it and redistribute it freely, subject to
the following restrictions:
1. The origin of this software must not be misrepresented; you must not claim
that you wrote the original software. If you use this software in a product,
an acknowledgment in the product documentation would be appreciated but is
not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
### Amendment
I, @Absolucy, fully give permission for any of my code (including the entirety of this project, tracing-oslog), anywhere, no matter the license, to be used to train machine learning models intended to be used for general-purpose programming or code analysis.

46
vendor/tracing-oslog/build.rs vendored Normal file
View File

@@ -0,0 +1,46 @@
use std::{env, path::PathBuf};
fn main() {
if env::var("CARGO_CFG_TARGET_VENDOR").expect("failed to get target vendor") != "apple" {
println!(
"cargo:warning=tracing-oslog is only available for Apple platforms, it will not log \
anything on other platforms!"
);
return;
}
let mut args = Vec::<String>::new();
let target_os = env::var("CARGO_CFG_TARGET_OS").expect("failed to get target os");
if target_os == "ios" {
let version = if "macabi" == env::var("CARGO_CFG_TARGET_ABI").unwrap_or_default() {
"14.0"
} else {
"10.0"
};
args.push(format!("-miphoneos-version-min={version}"));
} else if target_os == "macos" {
args.push("-mmacosx-version-min=10.12".to_owned());
}
let bindings = bindgen::Builder::default()
.header("wrapper.h")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
.allowlist_function("_?os_activity_.*")
.allowlist_function("os_log_.*")
.allowlist_function("os_release")
.allowlist_function("wrapped_.*")
.allowlist_type("os_activity_.*")
.allowlist_type("os_log_.*")
.allowlist_var("_?os_activity_.*")
.allowlist_var("__dso_handle")
.clang_args(&args)
.generate()
.expect("Unable to generate bindings");
// Write the bindings to the $OUT_DIR/bindings.rs file.
let out_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("bindings.rs");
bindings
.write_to_file(out_path)
.expect("Couldn't write bindings!");
cc::Build::new().file("wrapper.c").compile("wrapper");
}

7
vendor/tracing-oslog/src/ffi.rs vendored Normal file
View File

@@ -0,0 +1,7 @@
#![allow(
non_upper_case_globals,
non_camel_case_types,
non_snake_case,
dead_code
)]
include!(concat!(env!("OUT_DIR"), "/bindings.rs"));

18
vendor/tracing-oslog/src/lib.rs vendored Normal file
View File

@@ -0,0 +1,18 @@
#![deny(
clippy::complexity,
clippy::correctness,
clippy::perf,
clippy::style,
clippy::suspicious
)]
cfg_if::cfg_if! {
if #[cfg(target_vendor = "apple")] {
mod ffi;
mod logger;
mod visitor;
pub use logger::*;
} else {
mod stub;
pub use stub::*;
}
}

205
vendor/tracing-oslog/src/logger.rs vendored Normal file
View File

@@ -0,0 +1,205 @@
use crate::{
ffi::{
__dso_handle, _os_activity_create, _os_activity_current,
os_activity_flag_t_OS_ACTIVITY_FLAG_DEFAULT, os_activity_scope_enter,
os_activity_scope_leave, os_activity_scope_state_s, os_activity_scope_state_t,
os_activity_t, os_log_create, os_log_t, os_log_type_t_OS_LOG_TYPE_DEBUG,
os_log_type_t_OS_LOG_TYPE_ERROR, os_log_type_t_OS_LOG_TYPE_INFO, os_release,
wrapped_os_log_default, wrapped_os_log_with_type,
},
visitor::{AttributeMap, FieldVisitor},
};
use once_cell::sync::Lazy;
use parking_lot::Mutex;
use std::{collections::HashMap, ffi::CString, ops::Deref, ptr::addr_of_mut};
use tracing_core::{
span::{Attributes, Id},
Event, Level, Subscriber,
};
use tracing_subscriber::{
layer::{Context, Layer},
registry::LookupSpan,
};
static NAMES: Lazy<Mutex<HashMap<String, CString>>> = Lazy::new(Mutex::default);
struct Activity(os_activity_t);
// lol
unsafe impl Send for Activity {}
unsafe impl Sync for Activity {}
impl Deref for Activity {
type Target = os_activity_t;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl Drop for Activity {
fn drop(&mut self) {
unsafe {
os_release(self.0 as *mut _);
}
}
}
pub struct OsLogger {
logger: os_log_t,
}
impl Default for OsLogger {
fn default() -> Self {
Self {
logger: unsafe { wrapped_os_log_default() },
}
}
}
impl OsLogger {
/// Initialize a new `OsLogger`, which will output [tracing] events to
/// os_log on Apple platforms.
///
/// # Arguments
///
/// * `subsystem` - An identifier string, in reverse DNS notation, that
/// represents the subsystem thats performing logging, for example,
/// `com.your_company.your_subsystem_name`. The subsystem is used for
/// categorization and filtering of related log messages, as well as for
/// grouping related logging settings.
/// * `category` - A category within the specified subsystem. The system
/// uses the category to categorize and filter related log messages, as
/// well as to group related logging settings within the subsystems
/// settings. A categorys logging settings override those of the parent
/// subsystem.
pub fn new<S, C>(subsystem: S, category: C) -> Self
where
S: AsRef<str>,
C: AsRef<str>,
{
let subsystem = CString::new(subsystem.as_ref())
.expect("failed to construct C string from subsystem name");
let category = CString::new(category.as_ref())
.expect("failed to construct C string from category name");
let logger = unsafe { os_log_create(subsystem.as_ptr(), category.as_ptr()) };
Self { logger }
}
}
unsafe impl Sync for OsLogger {}
unsafe impl Send for OsLogger {}
impl<S> Layer<S> for OsLogger
where
S: Subscriber + for<'a> LookupSpan<'a>,
{
fn on_new_span(&self, attrs: &Attributes, id: &Id, ctx: Context<S>) {
let span = ctx.span(id).expect("invalid span, this shouldn't happen");
let mut extensions = span.extensions_mut();
if extensions.get_mut::<Activity>().is_none() {
let mut names = NAMES.lock();
let metadata = span.metadata();
let parent_activity = match span.parent() {
Some(parent) => **parent
.extensions()
.get::<Activity>()
.expect("parent span didn't contain activity wtf"),
None => unsafe { addr_of_mut!(_os_activity_current) },
};
let mut attributes = AttributeMap::default();
let mut attr_visitor = FieldVisitor::new(&mut attributes);
attrs.record(&mut attr_visitor);
let name = {
let function_name = [metadata.target(), metadata.name()].join("::");
let full_name = format!(
"{}({})",
function_name,
attributes
.into_iter()
.map(|(k, v)| format!("{}: {}", k, v))
.collect::<Vec<_>>()
.join(", ")
);
names.entry(full_name.clone()).or_insert_with(|| {
CString::new(full_name).expect("failed to construct C string from span name")
})
};
let activity = unsafe {
_os_activity_create(
addr_of_mut!(__dso_handle) as *mut _,
name.as_ptr(),
parent_activity,
os_activity_flag_t_OS_ACTIVITY_FLAG_DEFAULT,
)
};
extensions.insert(Activity(activity));
}
}
fn on_event(&self, event: &Event, ctx: Context<S>) {
let metadata = event.metadata();
let level = match *metadata.level() {
Level::TRACE => os_log_type_t_OS_LOG_TYPE_DEBUG,
Level::DEBUG => os_log_type_t_OS_LOG_TYPE_DEBUG,
Level::INFO => os_log_type_t_OS_LOG_TYPE_INFO,
Level::WARN => os_log_type_t_OS_LOG_TYPE_ERROR,
Level::ERROR => os_log_type_t_OS_LOG_TYPE_ERROR,
};
let mut attributes = AttributeMap::default();
let mut attr_visitor = FieldVisitor::new(&mut attributes);
event.record(&mut attr_visitor);
let mut message = String::new();
if let Some(value) = attributes.remove("message") {
message = value;
message.push_str(" ");
}
message.push_str(
&attributes
.into_iter()
.map(|(k, v)| format!("{}={}", k, v))
.collect::<Vec<_>>()
.join(" "),
);
message.retain(|c| c != '\0');
let message =
CString::new(message).expect("failed to convert formatted message to a C string");
if let Some(parent_id) = ctx.current_span().id() {
let span = ctx
.span(parent_id)
.expect("invalid span, this shouldn't happen");
let mut extensions = span.extensions_mut();
let activity = extensions
.get_mut::<Activity>()
.expect("span didn't contain activity wtf");
let raw_state = [0u64; 2usize];
unsafe {
let state: os_activity_scope_state_s = std::mem::transmute(raw_state);
let state: os_activity_scope_state_t = &state as *const _ as *mut _;
os_activity_scope_enter(**activity, state);
wrapped_os_log_with_type(self.logger, level, message.as_ptr());
os_activity_scope_leave(state);
}
} else {
unsafe { wrapped_os_log_with_type(self.logger, level, message.as_ptr()) };
}
}
fn on_enter(&self, _id: &Id, _ctx: Context<S>) {}
fn on_exit(&self, _id: &Id, _ctx: Context<S>) {}
fn on_close(&self, id: Id, ctx: Context<S>) {
let span = ctx.span(&id).expect("invalid span, this shouldn't happen");
let mut extensions = span.extensions_mut();
extensions
.remove::<Activity>()
.expect("span didn't contain activity wtf");
}
}
impl Drop for OsLogger {
fn drop(&mut self) {
unsafe {
os_release(self.logger as *mut _);
}
}
}

17
vendor/tracing-oslog/src/stub.rs vendored Normal file
View File

@@ -0,0 +1,17 @@
use tracing_core::Subscriber;
use tracing_subscriber::{layer::Layer, registry::LookupSpan};
pub struct OsLogger;
impl OsLogger {
pub fn new<S, C>(_subsystem: S, _category: C) -> Self
where
S: AsRef<str>,
C: AsRef<str>,
{
eprintln!("Initializing OsLogger on non-Apple platform! Nothing will be logged by it!");
Self
}
}
impl<S> Layer<S> for OsLogger where S: Subscriber + for<'a> LookupSpan<'a> {}

41
vendor/tracing-oslog/src/visitor.rs vendored Normal file
View File

@@ -0,0 +1,41 @@
use std::{collections::BTreeMap, fmt::Debug};
use tracing_core::field::{Field, Visit};
pub type AttributeMap = BTreeMap<String, String>;
pub struct FieldVisitor<'a> {
output: &'a mut AttributeMap,
}
impl<'a> FieldVisitor<'a> {
pub fn new(output: &'a mut AttributeMap) -> Self {
FieldVisitor { output }
}
}
impl<'a> Visit for FieldVisitor<'a> {
fn record_i64(&mut self, field: &Field, value: i64) {
self.output
.insert(field.name().to_string(), value.to_string());
}
fn record_u64(&mut self, field: &Field, value: u64) {
self.output
.insert(field.name().to_string(), value.to_string());
}
fn record_bool(&mut self, field: &Field, value: bool) {
self.output
.insert(field.name().to_string(), value.to_string());
}
fn record_str(&mut self, field: &Field, value: &str) {
self.output
.insert(field.name().to_string(), format!("\"{}\"", value));
}
fn record_debug(&mut self, field: &Field, value: &dyn Debug) {
self.output
.insert(field.name().to_string(), format!("{:?}", value));
}
}

8
vendor/tracing-oslog/wrapper.c vendored Normal file
View File

@@ -0,0 +1,8 @@
#include "wrapper.h"
void wrapped_os_log_with_type(os_log_t log, os_log_type_t type, const char* message) {
os_log_with_type(log, type, "%{public}s", message);
}
os_log_t wrapped_os_log_default(void) {
return OS_LOG_DEFAULT;
}

5
vendor/tracing-oslog/wrapper.h vendored Normal file
View File

@@ -0,0 +1,5 @@
#include <os/log.h>
#include <os/activity.h>
void wrapped_os_log_with_type(os_log_t log, os_log_type_t type, const char *message);
os_log_t wrapped_os_log_default(void);