commit fb485a6c1c3b95fec369c3ccd9c20aad4a67a7f7 Author: Pakin Date: Mon Aug 4 08:11:35 2025 +0700 v1 init diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..f92b1a3 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,1892 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "addr2line" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler2" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa" + +[[package]] +name = "aho-corasick" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "android-tzdata" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e999941b234f3131b00bc13c22d06e8c5ff726d1b6318ac7eb276997bbb4fef0" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "anstream" +version = "0.6.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "301af1932e46185686725e0fad2f8f2aa7da69dd70bf6ecc44d6b703844a3933" +dependencies = [ + "anstyle", + "anstyle-parse", + "anstyle-query", + "anstyle-wincon", + "colorchoice", + "is_terminal_polyfill", + "utf8parse", +] + +[[package]] +name = "anstyle" +version = "1.0.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "862ed96ca487e809f1c8e5a8447f6ee2cf102f846893800b20cebdf541fc6bbd" + +[[package]] +name = "anstyle-parse" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4e7644824f0aa2c7b9384579234ef10eb7efb6a0deb83f9630a49594dd9c15c2" +dependencies = [ + "utf8parse", +] + +[[package]] +name = "anstyle-query" +version = "1.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8bdeb6047d8983be085bab0ba1472e6dc604e7041dbf6fcd5e71523014fae9" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "anstyle-wincon" +version = "3.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "403f75924867bb1033c59fbf0797484329750cfbe3c4325cd33127941fabc882" +dependencies = [ + "anstyle", + "once_cell_polyfill", + "windows-sys 0.59.0", +] + +[[package]] +name = "atomic-waker" +version = "1.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0" + +[[package]] +name = "autocfg" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c08606f8c3cbf4ce6ec8e28fb0014a2c086708fe954eaa885384a6165172e7e8" + +[[package]] +name = "backtrace" +version = "0.3.75" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6806a6321ec58106fea15becdad98371e28d92ccbc7c8f1b3b6dd724fe8f1002" +dependencies = [ + "addr2line", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", + "windows-targets", +] + +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + +[[package]] +name = "bitflags" +version = "2.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b8e56985ec62d17e9c1001dc89c88ecd7dc08e47eba5ec7c29c7b5eeecde967" + +[[package]] +name = "bumpalo" +version = "3.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43" + +[[package]] +name = "bytes" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" + +[[package]] +name = "cc" +version = "1.2.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c3a42d84bb6b69d3a8b3eaacf0d88f179e1929695e1ad012b6cf64d9caaa5fd2" +dependencies = [ + "shlex", +] + +[[package]] +name = "cfg-if" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9555578bc9e57714c812a1f84e4fc5b4d21fcb063490c624de019f7464c91268" + +[[package]] +name = "chrono" +version = "0.4.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c469d952047f47f91b68d1cba3f10d63c11d73e4636f24f08daf0278abf01c4d" +dependencies = [ + "android-tzdata", + "iana-time-zone", + "js-sys", + "num-traits", + "serde", + "wasm-bindgen", + "windows-link", +] + +[[package]] +name = "clap" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ed87a9d530bb41a67537289bafcac159cb3ee28460e0a4571123d2a778a6a882" +dependencies = [ + "clap_builder", + "clap_derive", +] + +[[package]] +name = "clap_builder" +version = "4.5.42" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64f4f3f3c77c94aff3c7e9aac9a2ca1974a5adf392a8bb751e827d6d127ab966" +dependencies = [ + "anstream", + "anstyle", + "clap_lex", + "strsim", +] + +[[package]] +name = "clap_derive" +version = "4.5.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef4f52386a59ca4c860f7393bcf8abd8dfd91ecccc0f774635ff68e92eeef491" +dependencies = [ + "heck", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "clap_lex" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b94f61472cee1439c0b966b47e3aca9ae07e45d070759512cd390ea2bebc6675" + +[[package]] +name = "colorchoice" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b05b61dc5112cbb17e4b6cd61790d9845d13888356391624cbe7e41efeac1e75" + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b" + +[[package]] +name = "displaydoc" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97369cbbc041bc366949bc74d34658d6cda5621039731c6310521892a3a20ae0" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "encoding_rs" +version = "0.8.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75030f3c4f45dafd7586dd6780965a8c7e8e285a5ecb86713e63a79c5b2766f3" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "equivalent" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" + +[[package]] +name = "errno" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "778e2ac28f6c47af28e4907f13ffd1e1ddbd400980a9abd7c8df189bf578a5ad" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e13624c2627564efccf4934284bdd98cbaa14e79b0b5a141218e507b3a823456" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" + +[[package]] +name = "futures-sink" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" + +[[package]] +name = "futures-task" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" + +[[package]] +name = "futures-util" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" +dependencies = [ + "futures-core", + "futures-task", + "pin-project-lite", + "pin-utils", +] + +[[package]] +name = "getrandom" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "335ff9f135e4384c8150d6f27c6daed433577f86b4750418338c01a1a2528592" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4" +dependencies = [ + "cfg-if", + "libc", + "r-efi", + "wasi 0.14.2+wasi-0.2.4", +] + +[[package]] +name = "gimli" +version = "0.31.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" + +[[package]] +name = "h2" +version = "0.4.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17da50a276f1e01e0ba6c029e47b7100754904ee8a278f886546e98575380785" +dependencies = [ + "atomic-waker", + "bytes", + "fnv", + "futures-core", + "futures-sink", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.15.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5971ac85611da7067dbfcabef3c70ebb5606018acd9e2a3903a0da507521e0d5" + +[[package]] +name = "heck" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea" + +[[package]] +name = "http" +version = "1.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" +dependencies = [ + "bytes", + "http", +] + +[[package]] +name = "http-body-util" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b021d93e26becf5dc7e1b75b1bed1fd93124b374ceb73f43d4d4eafec896a64a" +dependencies = [ + "bytes", + "futures-core", + "http", + "http-body", + "pin-project-lite", +] + +[[package]] +name = "httparse" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dbf3de79e51f3d586ab4cb9d5c3e2c14aa28ed23d180cf89b4df0454a69cc87" + +[[package]] +name = "hyper" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc2b571658e38e0c01b1fdca3bbbe93c00d3d71693ff2770043f8c29bc7d6f80" +dependencies = [ + "bytes", + "futures-channel", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "itoa", + "pin-project-lite", + "smallvec", + "tokio", + "want", +] + +[[package]] +name = "hyper-rustls" +version = "0.27.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3c93eb611681b207e1fe55d5a71ecf91572ec8a6705cdb6857f7d8d5242cf58" +dependencies = [ + "http", + "hyper", + "hyper-util", + "rustls", + "rustls-pki-types", + "tokio", + "tokio-rustls", + "tower-service", +] + +[[package]] +name = "hyper-tls" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0" +dependencies = [ + "bytes", + "http-body-util", + "hyper", + "hyper-util", + "native-tls", + "tokio", + "tokio-native-tls", + "tower-service", +] + +[[package]] +name = "hyper-util" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8d9b05277c7e8da2c93a568989bb6207bef0112e8d17df7a6eda4a3cf143bc5e" +dependencies = [ + "base64", + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "http", + "http-body", + "hyper", + "ipnet", + "libc", + "percent-encoding", + "pin-project-lite", + "socket2", + "system-configuration", + "tokio", + "tower-service", + "tracing", + "windows-registry", +] + +[[package]] +name = "iana-time-zone" +version = "0.1.63" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0c919e5debc312ad217002b8048a17b7d83f80703865bbfcfebb0458b0b27d8" +dependencies = [ + "android_system_properties", + "core-foundation-sys", + "iana-time-zone-haiku", + "js-sys", + "log", + "wasm-bindgen", + "windows-core", +] + +[[package]] +name = "iana-time-zone-haiku" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f31827a206f56af32e590ba56d5d2d085f558508192593743f16b2306495269f" +dependencies = [ + "cc", +] + +[[package]] +name = "icu_collections" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "200072f5d0e3614556f94a9930d5dc3e0662a652823904c3a75dc3b0af7fee47" +dependencies = [ + "displaydoc", + "potential_utf", + "yoke", + "zerofrom", + "zerovec", +] + +[[package]] +name = "icu_locale_core" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0cde2700ccaed3872079a65fb1a78f6c0a36c91570f28755dda67bc8f7d9f00a" +dependencies = [ + "displaydoc", + "litemap", + "tinystr", + "writeable", + "zerovec", +] + +[[package]] +name = "icu_normalizer" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "436880e8e18df4d7bbc06d58432329d6458cc84531f7ac5f024e93deadb37979" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_normalizer_data", + "icu_properties", + "icu_provider", + "smallvec", + "zerovec", +] + +[[package]] +name = "icu_normalizer_data" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00210d6893afc98edb752b664b8890f0ef174c8adbb8d0be9710fa66fbbf72d3" + +[[package]] +name = "icu_properties" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "016c619c1eeb94efb86809b015c58f479963de65bdb6253345c1a1276f22e32b" +dependencies = [ + "displaydoc", + "icu_collections", + "icu_locale_core", + "icu_properties_data", + "icu_provider", + "potential_utf", + "zerotrie", + "zerovec", +] + +[[package]] +name = "icu_properties_data" +version = "2.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "298459143998310acd25ffe6810ed544932242d3f07083eee1084d83a71bd632" + +[[package]] +name = "icu_provider" +version = "2.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03c80da27b5f4187909049ee2d72f276f0d9f99a42c306bd0131ecfe04d8e5af" +dependencies = [ + "displaydoc", + "icu_locale_core", + "stable_deref_trait", + "tinystr", + "writeable", + "yoke", + "zerofrom", + "zerotrie", + "zerovec", +] + +[[package]] +name = "idna" +version = "1.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "686f825264d630750a544639377bae737628043f20d38bbc029e8f29ea968a7e" +dependencies = [ + "idna_adapter", + "smallvec", + "utf8_iter", +] + +[[package]] +name = "idna_adapter" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3acae9609540aa318d1bc588455225fb2085b9ed0c4f6bd0d9d5bcd86f1a0344" +dependencies = [ + "icu_normalizer", + "icu_properties", +] + +[[package]] +name = "indexmap" +version = "2.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fe4cd85333e22411419a0bcae1297d25e58c9443848b11dc6a86fefe8c78a661" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "io-uring" +version = "0.7.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d93587f37623a1a17d94ef2bc9ada592f5465fe7732084ab7beefabe5c77c0c4" +dependencies = [ + "bitflags", + "cfg-if", + "libc", +] + +[[package]] +name = "ipnet" +version = "2.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "469fb0b9cefa57e3ef31275ee7cacb78f2fdca44e4765491884a2b119d4eb130" + +[[package]] +name = "iri-string" +version = "0.7.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbc5ebe9c3a1a7a5127f920a418f7585e9e758e911d0466ed004f393b0e380b2" +dependencies = [ + "memchr", + "serde", +] + +[[package]] +name = "is_terminal_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf" + +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + +[[package]] +name = "js-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f" +dependencies = [ + "once_cell", + "wasm-bindgen", +] + +[[package]] +name = "libc" +version = "0.2.174" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1171693293099992e19cddea4e8b849964e9846f4acee11b3948bcc337be8776" + +[[package]] +name = "linux-raw-sys" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cd945864f07fe9f5371a27ad7b52a172b4b499999f1d97574c9fa68373937e12" + +[[package]] +name = "litemap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "241eaef5fd12c88705a01fc1066c48c4b36e0dd4377dcdc7ec3942cea7a69956" + +[[package]] +name = "lock_api" +version = "0.4.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96936507f153605bddfcda068dd804796c84324ed2510809e5b2a624c81da765" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13dc2df351e3202783a1fe0d44375f7295ffb4049267b0f3018346dc122a1d94" + +[[package]] +name = "log-analyzer" +version = "0.1.0" +dependencies = [ + "chrono", + "clap", + "regex", + "reqwest", + "serde", + "serde_json", + "tokio", + "walkdir", +] + +[[package]] +name = "memchr" +version = "2.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a282da65faaf38286cf3be983213fcf1d2e2a58700e808f83f4ea9a4804bc0" + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "miniz_oxide" +version = "0.8.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316" +dependencies = [ + "adler2", +] + +[[package]] +name = "mio" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78bed444cc8a2160f01cbcf811ef18cac863ad68ae8ca62092e8db51d51c761c" +dependencies = [ + "libc", + "wasi 0.11.1+wasi-snapshot-preview1", + "windows-sys 0.59.0", +] + +[[package]] +name = "native-tls" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87de3442987e9dbec73158d5c715e7ad9072fda936bb03d19d7fa10e00520f0e" +dependencies = [ + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "object" +version = "0.36.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87" +dependencies = [ + "memchr", +] + +[[package]] +name = "once_cell" +version = "1.21.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" + +[[package]] +name = "once_cell_polyfill" +version = "1.70.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4895175b425cb1f87721b59f0f286c2092bd4af812243672510e1ac53e2e0ad" + +[[package]] +name = "openssl" +version = "0.10.73" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8505734d46c8ab1e19a1dce3aef597ad87dcb4c37e7188231769bd6bd51cebf8" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "90096e2e47630d78b7d1c20952dc621f957103f8bc2c8359ec81290d75238571" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "parking_lot" +version = "0.12.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70d58bf43669b5795d1576d0641cfb6fbb2057bf629506267a92807158584a13" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bc838d2a56b5b1a6c25f55575dfc605fabb63bb2365f6c2353ef9159aa69e4a5" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "percent-encoding" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" + +[[package]] +name = "pin-project-lite" +version = "0.2.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7edddbd0b52d732b21ad9a5fab5c704c14cd949e5e9a1ec5929a24fded1b904c" + +[[package]] +name = "potential_utf" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5a7c30837279ca13e7c867e9e40053bc68740f988cb07f7ca6df43cc734b585" +dependencies = [ + "zerovec", +] + +[[package]] +name = "proc-macro2" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.40" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "r-efi" +version = "5.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f" + +[[package]] +name = "redox_syscall" +version = "0.5.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5407465600fb0548f1442edf71dd20683c6ed326200ace4b1ef0763521bb3b77" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "reqwest" +version = "0.12.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbc931937e6ca3a06e3b6c0aa7841849b160a90351d6ab467a8b9b9959767531" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-rustls", + "hyper-tls", + "hyper-util", + "js-sys", + "log", + "mime", + "native-tls", + "percent-encoding", + "pin-project-lite", + "rustls-pki-types", + "serde", + "serde_json", + "serde_urlencoded", + "sync_wrapper", + "tokio", + "tokio-native-tls", + "tower", + "tower-http", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", +] + +[[package]] +name = "ring" +version = "0.17.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4689e6c2294d81e88dc6261c768b63bc4fcdb852be6d1352498b114f61383b7" +dependencies = [ + "cc", + "cfg-if", + "getrandom 0.2.16", + "libc", + "untrusted", + "windows-sys 0.52.0", +] + +[[package]] +name = "rustc-demangle" +version = "0.1.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f7d92ca342cea22a06f2121d944b4fd82af56988c270852495420f961d4ace" + +[[package]] +name = "rustix" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11181fbabf243db407ef8df94a6ce0b2f9a733bd8be4ad02b4eda9602296cac8" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys 0.59.0", +] + +[[package]] +name = "rustls" +version = "0.23.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0ebcbd2f03de0fc1122ad9bb24b127a5a6cd51d72604a3f3c50ac459762b6cc" +dependencies = [ + "once_cell", + "rustls-pki-types", + "rustls-webpki", + "subtle", + "zeroize", +] + +[[package]] +name = "rustls-pki-types" +version = "1.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "229a4a4c221013e7e1f1a043678c5cc39fe5171437c88fb47151a21e6f5b5c79" +dependencies = [ + "zeroize", +] + +[[package]] +name = "rustls-webpki" +version = "0.103.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0a17884ae0c1b773f1ccd2bd4a8c72f16da897310a98b0e84bf349ad5ead92fc" +dependencies = [ + "ring", + "rustls-pki-types", + "untrusted", +] + +[[package]] +name = "rustversion" +version = "1.0.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a0d197bd2c9dc6e53b84da9556a69ba4cdfab8619eb41a8bd1cc2027a0f6b1d" + +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + +[[package]] +name = "same-file" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "93fc1dc3aaa9bfed95e02e6eadabb4baf7e3078b0bd1b4d7b6b0b68378900502" +dependencies = [ + "winapi-util", +] + +[[package]] +name = "schannel" +version = "0.1.27" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f29ebaa345f945cec9fbbc532eb307f0fdad8161f281b6369539c8d84876b3d" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "security-framework" +version = "2.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49db231d56a190491cb4aeda9527f1ad45345af50b0851622a7adb8c03b01c32" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6" +dependencies = [ + "serde_derive", +] + +[[package]] +name = "serde_derive" +version = "1.0.219" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "serde_json" +version = "1.0.142" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "030fedb782600dcbd6f02d479bf0d817ac3bb40d644745b769d6a96bc3afc5a7" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "signal-hook-registry" +version = "1.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9203b8055f63a2a00e2f593bb0510367fe707d7ff1e5c872de2f537b339e5410" +dependencies = [ + "libc", +] + +[[package]] +name = "slab" +version = "0.4.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04dc19736151f35336d325007ac991178d504a119863a2fcb3758cdb5e52c50d" + +[[package]] +name = "smallvec" +version = "1.15.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67b1b7a3b5fe4f1376887184045fcf45c69e92af734b7aaddc05fb777b6fbd03" + +[[package]] +name = "socket2" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807" +dependencies = [ + "libc", + "windows-sys 0.59.0", +] + +[[package]] +name = "stable_deref_trait" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3" + +[[package]] +name = "strsim" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" + +[[package]] +name = "subtle" +version = "2.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" + +[[package]] +name = "syn" +version = "2.0.104" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17b6f705963418cdb9927482fa304bc562ece2fdd4f616084c50b7023b435a40" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "sync_wrapper" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263" +dependencies = [ + "futures-core", +] + +[[package]] +name = "synstructure" +version = "0.13.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "728a70f3dbaf5bab7f0c4b1ac8d7ae5ea60a4b5549c8a5914361c99147a709d2" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "system-configuration" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b" +dependencies = [ + "bitflags", + "core-foundation", + "system-configuration-sys", +] + +[[package]] +name = "system-configuration-sys" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "tempfile" +version = "3.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8a64e3985349f2441a1a9ef0b853f869006c3855f2cda6862a94d26ebb9d6a1" +dependencies = [ + "fastrand", + "getrandom 0.3.3", + "once_cell", + "rustix", + "windows-sys 0.59.0", +] + +[[package]] +name = "tinystr" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5d4f6d1145dcb577acf783d4e601bc1d76a13337bb54e6233add580b07344c8b" +dependencies = [ + "displaydoc", + "zerovec", +] + +[[package]] +name = "tokio" +version = "1.47.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038" +dependencies = [ + "backtrace", + "bytes", + "io-uring", + "libc", + "mio", + "parking_lot", + "pin-project-lite", + "signal-hook-registry", + "slab", + "socket2", + "tokio-macros", + "windows-sys 0.59.0", +] + +[[package]] +name = "tokio-macros" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-rustls" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e727b36a1a0e8b74c376ac2211e40c2c8af09fb4013c60d910495810f008e9b" +dependencies = [ + "rustls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "66a539a9ad6d5d281510d5bd368c973d636c02dbf8a67300bfb6b950696ad7df" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", +] + +[[package]] +name = "tower" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9" +dependencies = [ + "futures-core", + "futures-util", + "pin-project-lite", + "sync_wrapper", + "tokio", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-http" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "adc82fd73de2a9722ac5da747f12383d2bfdb93591ee6c58486e0097890f05f2" +dependencies = [ + "bitflags", + "bytes", + "futures-util", + "http", + "http-body", + "iri-string", + "pin-project-lite", + "tower", + "tower-layer", + "tower-service", +] + +[[package]] +name = "tower-layer" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e" + +[[package]] +name = "tower-service" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8df9b6e13f2d32c91b9bd719c00d1958837bc7dec474d94952798cc8e69eeec3" + +[[package]] +name = "tracing" +version = "0.1.41" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" +dependencies = [ + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b" + +[[package]] +name = "unicode-ident" +version = "1.0.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" + +[[package]] +name = "untrusted" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" + +[[package]] +name = "url" +version = "2.5.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32f8b686cadd1473f4bd0117a5d28d36b1ade384ea9b5069a1c40aefed7fda60" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "utf8_iter" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be" + +[[package]] +name = "utf8parse" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821" + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "walkdir" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" +dependencies = [ + "same-file", + "winapi-util", +] + +[[package]] +name = "want" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bfa7760aed19e106de2c7c0b581b509f2f25d3dacaf737cb82ac61bc6d760b0e" +dependencies = [ + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.1+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b" + +[[package]] +name = "wasi" +version = "0.14.2+wasi-0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9683f9a5a998d873c0d21fcbe3c083009670149a8fab228644b8bd36b2c48cb3" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "wasm-bindgen" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5" +dependencies = [ + "cfg-if", + "once_cell", + "rustversion", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6" +dependencies = [ + "bumpalo", + "log", + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61" +dependencies = [ + "cfg-if", + "js-sys", + "once_cell", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.100" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "web-sys" +version = "0.3.77" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi-util" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb" +dependencies = [ + "windows-sys 0.59.0", +] + +[[package]] +name = "windows-core" +version = "0.61.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c0fdd3ddb90610c7638aa2b3a3ab2904fb9e5cdbecc643ddb3647212781c4ae3" +dependencies = [ + "windows-implement", + "windows-interface", + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-implement" +version = "0.60.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a47fddd13af08290e67f4acabf4b459f647552718f683a7b415d290ac744a836" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-interface" +version = "0.59.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd9211b69f8dcdfa817bfd14bf1c97c9188afa36f4750130fcdf3f400eca9fa8" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "windows-link" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e6ad25900d524eaabdbbb96d20b4311e1e7ae1699af4fb28c17ae66c80d798a" + +[[package]] +name = "windows-registry" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b8a9ed28765efc97bbc954883f4e6796c33a06546ebafacbabee9696967499e" +dependencies = [ + "windows-link", + "windows-result", + "windows-strings", +] + +[[package]] +name = "windows-result" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56f42bd332cc6c8eac5af113fc0c1fd6a8fd2aa08a0119358686e5160d0586c6" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-strings" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56e6c93f3a0c3b36176cb1327a4958a0353d5d166c2a35cb268ace15e91d3b57" +dependencies = [ + "windows-link", +] + +[[package]] +name = "windows-sys" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.39.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f42320e61fe2cfd34354ecb597f86f413484a798ba44a8ca1165c58d42da6c1" +dependencies = [ + "bitflags", +] + +[[package]] +name = "writeable" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea2f10b9bb0928dfb1b42b65e1f9e36f7f54dbdf08457afefb38afcdec4fa2bb" + +[[package]] +name = "yoke" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f41bb01b8226ef4bfd589436a297c53d118f65921786300e427be8d487695cc" +dependencies = [ + "serde", + "stable_deref_trait", + "yoke-derive", + "zerofrom", +] + +[[package]] +name = "yoke-derive" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38da3c9736e16c5d3c8c597a9aaa5d1fa565d0532ae05e27c24aa62fb32c0ab6" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zerofrom" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50cc42e0333e05660c3587f3bf9d0478688e15d870fab3346451ce7f8c9fbea5" +dependencies = [ + "zerofrom-derive", +] + +[[package]] +name = "zerofrom-derive" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d71e5d6e06ab090c67b5e44993ec16b72dcbaabc526db883a360057678b48502" +dependencies = [ + "proc-macro2", + "quote", + "syn", + "synstructure", +] + +[[package]] +name = "zeroize" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde" + +[[package]] +name = "zerotrie" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36f0bbd478583f79edad978b407914f61b2972f5af6fa089686016be8f9af595" +dependencies = [ + "displaydoc", + "yoke", + "zerofrom", +] + +[[package]] +name = "zerovec" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a05eb080e015ba39cc9e23bbe5e7fb04d5fb040350f99f34e338d5fdd294428" +dependencies = [ + "yoke", + "zerofrom", + "zerovec-derive", +] + +[[package]] +name = "zerovec-derive" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b96237efa0c878c64bd89c436f661be4e46b2f3eff1ebb976f7ef2321d2f58f" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..a30b631 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "log-analyzer" +version = "0.1.0" +edition = "2024" + +[dependencies] +chrono = { version = "0.4.41", features = ["serde"] } +clap = { version = "4.5.42", features = ["derive"] } +regex = "1.11.1" +reqwest = { version = "0.12.22", features = ["json"] } +serde = { version = "1.0.219", features = ["derive"] } +serde_json = "1.0.142" +tokio = { version = "1.47.1", features = ["full"] } +walkdir = "2.5.0" diff --git a/README.md b/README.md new file mode 100644 index 0000000..5b3ac74 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Analyze logs with source code correlation +./logcat_analyzer -f logcat.txt --source /path/to/android/src + +# This scans your Java/Kotlin files and correlates them with log entries + + +# AI analysis with source code context +./logcat_analyzer -f logcat.txt --source ./app/src/main/java --ai + +# Filter errors and show source locations +./logcat_analyzer -f logcat.txt --source ./src -l E + +# Find crashes with exact code locations +./logcat_analyzer -f logcat.txt --source ./app/src --crashes + +# Set up source directory +export ANDROID_SOURCE_DIR=/path/to/your/android/project/src + +./logcat_analyzer -f logcat.txt --source $ANDROID_SOURCE_DIR --ai \ No newline at end of file diff --git a/src/ai/analyzer.rs b/src/ai/analyzer.rs new file mode 100644 index 0000000..afe7ebd --- /dev/null +++ b/src/ai/analyzer.rs @@ -0,0 +1,356 @@ +use crate::logcat::logcat_analyzer::LogcatAnalyzer; +use crate::model::{ + ai::{AIAnalysisRequest, AIInsight, AnomalyType}, + log_entry::{LogEntry, LogLevel}, +}; + +pub struct LocalAiLogAnalyzer { + ollama_host: String, + model_name: String, + client: reqwest::Client, +} + +impl LocalAiLogAnalyzer { + pub fn new(ollama_host: Option, model_name: Option) -> Self { + Self { + ollama_host: ollama_host.unwrap_or_else(|| "http://localhost:11434".to_string()), + model_name: model_name.unwrap_or_else(|| "llama3.1".to_string()), + client: reqwest::Client::new(), + } + } + + pub async fn analyze_logs( + &self, + analyzer: &LogcatAnalyzer, + entries: &[&LogEntry], + ) -> Result, Box> { + if !self.check_ollama_availability().await { + return Ok(self.generate_offline_insights(analyzer, entries)); + } + + let analysis_request = self.prepare_analysis_request(analyzer, entries); + let insights = self.call_ollama_api(analysis_request).await?; + + Ok(insights) + } + + fn prepare_analysis_request( + &self, + analyzer: &LogcatAnalyzer, + entries: &[&LogEntry], + ) -> AIAnalysisRequest { + let log_summary = format!( + "Total entries: {}, Errors: {}, Crashes: {}, With source code: {}", + entries.len(), + entries + .iter() + .filter(|e| matches!(e.level, LogLevel::Error | LogLevel::Fatal)) + .count(), + analyzer.find_crashes().len(), + entries + .iter() + .filter(|e| e.source_location.is_some()) + .count() + ); + + let error_patterns: Vec = entries + .iter() + .filter(|e| matches!(e.level, LogLevel::Error | LogLevel::Fatal)) + .take(10) + .map(|e| { + let source_info = if let Some(source) = &e.source_location { + format!( + " [{}:{}]", + source.file_path, + source.line_number.unwrap_or(0) + ) + } else { + String::new() + }; + format!( + "[{}] {}: {}{}", + format!("{:?}", e.level), + e.tag, + e.message, + source_info + ) + }) + .collect(); + + let crash_entries: Vec = analyzer + .find_crashes() + .iter() + .take(5) + .map(|e| { + let source_info = if let Some(source) = &e.source_location { + format!( + " [{}:{}]", + source.file_path, + source.line_number.unwrap_or(0) + ) + } else { + String::new() + }; + format!( + "[{}] {}: {}{}", + format!("{:?}", e.level), + e.tag, + e.message, + source_info + ) + }) + .collect(); + + let anomalies: Vec = analyzer + .detect_anomalies() + .iter() + .take(5) + .map(|a| format!("{:?}: {}", a.anomaly_type, a.description)) + .collect(); + + // Add source code context for critical entries + let source_code_context: Vec = entries + .iter() + .filter(|e| { + e.source_location.is_some() && matches!(e.level, LogLevel::Error | LogLevel::Fatal) + }) + .take(5) + .filter_map(|e| { + e.source_location.as_ref().map(|source| { + format!( + "File: {}, Method: {}, Context:\n{}", + source.file_path, + source.method_name.as_deref().unwrap_or("unknown"), + source.code_context.join("\n") + ) + }) + }) + .collect(); + + // Add code quality issues if available + let code_quality_issues: Vec = + if let Some(source_analyzer) = &analyzer.source_analyzer { + source_analyzer + .analyze_code_quality(entries) + .iter() + .map(|issue| { + format!( + "{:?}: {} ({})", + issue.issue_type, issue.description, issue.severity + ) + }) + .collect() + } else { + Vec::new() + }; + + AIAnalysisRequest { + log_summary, + error_patterns, + crash_entries, + anomalies, + source_code_context, + code_quality_issues, + context: "Android application logcat analysis with source code correlation".to_string(), + } + } + + async fn check_ollama_availability(&self) -> bool { + match self + .client + .get(&format!("{}/api/tags", self.ollama_host)) + .send() + .await + { + Ok(response) => response.status().is_success(), + Err(_) => false, + } + } + + async fn call_ollama_api( + &self, + request: AIAnalysisRequest, + ) -> Result, Box> { + let prompt = format!( + r#"You are an expert Android developer and log analysis specialist. Analyze the following Android logcat data WITH source code context and provide structured insights. + + Log Summary: {} + Error Patterns: {:?} + Crash Entries: {:?} + Detected Anomalies: {:?} + Source Code Context: {:?} + Code Quality Issues: {:?} + + IMPORTANT: You have access to source code context. Use this to provide deeper analysis about: + 1. Root causes of errors based on the actual code + 2. Specific code improvements and fixes + 3. Code quality issues and best practices violations + 4. Performance bottlenecks visible in the source + 5. Security vulnerabilities in the code + + Please analyze this data and provide insights in the following JSON format (respond with ONLY valid JSON, no additional text): + [{{ + "category": "error_analysis", + "severity": "high", + "description": "Brief description of the issue with source code reference", + "recommendation": "Specific code changes and improvements", + "confidence": 0.8, + "source_file": "filename.java", + "line_number": 123 + }}] + + Categories can be: error_analysis, performance, crashes, security, code_quality, best_practices + Severity levels: low, medium, high, critical + Confidence should be between 0.0 and 1.0 + + Focus on actionable code-level insights that help developers fix specific issues in their Android application source code."#, + request.log_summary, + request.error_patterns, + request.crash_entries, + request.anomalies, + request.source_code_context, + request.code_quality_issues + ); + + let payload = serde_json::json!({ + "model": self.model_name, + "prompt": prompt, + "stream": false, + "options": { + "temperature": 0.3, + "top_p": 0.9, + "max_tokens": 2000 + } + }); + + let response = self + .client + .post(&format!("{}/api/generate", self.ollama_host)) + .header("Content-Type", "application/json") + .json(&payload) + .send() + .await?; + + if !response.status().is_success() { + return Err(format!("Ollama API error: {}", response.status()).into()); + } + + let response_json: serde_json::Value = response.json().await?; + + if let Some(response_text) = response_json.get("response").and_then(|v| v.as_str()) { + self.parse_ollama_response(response_text) + } else { + Err("Invalid response format from Ollama".into()) + } + } + + fn parse_ollama_response( + &self, + response: &str, + ) -> Result, Box> { + // Try to extract JSON from the response + let json_start = response.find('[').unwrap_or(0); + let json_end = response.rfind(']').map(|i| i + 1).unwrap_or(response.len()); + let json_str = &response[json_start..json_end]; + + match serde_json::from_str::>(json_str) { + Ok(insights) => Ok(insights), + Err(e) => { + println!("Warning: Failed to parse AI response as JSON: {}", e); + println!("Raw response: {}", response); + // Fallback to a generic insight + Ok(vec![AIInsight { + category: "ai_analysis".to_string(), + severity: "medium".to_string(), + description: "AI analysis completed with parsing issues".to_string(), + recommendation: "Review the log analysis manually for best results".to_string(), + confidence: 0.5, + }]) + } + } + } + + fn generate_offline_insights( + &self, + analyzer: &LogcatAnalyzer, + entries: &[&LogEntry], + ) -> Vec { + let mut insights = Vec::new(); + + // Analyze error frequency + let error_count = entries + .iter() + .filter(|e| matches!(e.level, LogLevel::Error)) + .count(); + let total_count = entries.len(); + + if error_count as f32 / total_count as f32 > 0.1 { + insights.push(AIInsight { + category: "error_analysis".to_string(), + severity: "high".to_string(), + description: format!( + "High error rate detected: {}/{} entries are errors", + error_count, total_count + ), + recommendation: "Review error patterns and implement error handling".to_string(), + confidence: 0.9, + }); + } + + // Analyze crashes + let crashes = analyzer.find_crashes(); + if !crashes.is_empty() { + insights.push(AIInsight { + category: "crashes".to_string(), + severity: "critical".to_string(), + description: format!("Found {} potential crashes or exceptions", crashes.len()), + recommendation: "Investigate crash logs and implement proper exception handling" + .to_string(), + confidence: 0.95, + }); + } + + // Analyze anomalies + let anomalies = analyzer.detect_anomalies(); + for anomaly in anomalies { + let severity = match anomaly.severity { + s if s > 0.8 => "high", + s if s > 0.5 => "medium", + _ => "low", + }; + + insights.push(AIInsight { + category: "anomaly_detection".to_string(), + severity: severity.to_string(), + description: anomaly.description, + recommendation: self.get_anomaly_recommendation(&anomaly.anomaly_type), + confidence: anomaly.severity, + }); + } + + insights + } + + fn get_anomaly_recommendation(&self, anomaly_type: &AnomalyType) -> String { + match anomaly_type { + AnomalyType::FrequencySpike => { + "Monitor system resources and optimize logging frequency".to_string() + } + AnomalyType::UnusualErrorPattern => { + "Investigate new error patterns and update error handling".to_string() + } + AnomalyType::MemoryLeak => { + "Profile memory usage and fix potential memory leaks".to_string() + } + AnomalyType::PerformanceDegradation => { + "Analyze performance bottlenecks and optimize critical paths".to_string() + } + AnomalyType::CrashLoop => { + "Fix underlying crash causes to prevent restart loops".to_string() + } + AnomalyType::SuspiciousActivity => { + "Review security implications and implement additional monitoring".to_string() + } + } + } +} diff --git a/src/ai/mod.rs b/src/ai/mod.rs new file mode 100644 index 0000000..aaf41a3 --- /dev/null +++ b/src/ai/mod.rs @@ -0,0 +1 @@ +pub mod analyzer; diff --git a/src/logcat/logcat_analyzer.rs b/src/logcat/logcat_analyzer.rs new file mode 100644 index 0000000..cfd7b2a --- /dev/null +++ b/src/logcat/logcat_analyzer.rs @@ -0,0 +1,684 @@ +use chrono::{Duration, NaiveDateTime}; +use regex::Regex; +use std::collections::HashMap; +use std::fs::File; +use std::io::{BufRead, BufReader, Read}; +use std::path::Path; + +use crate::model::{ + ai::{AnomalyType, LogAnomaly}, + log_entry::{LogEntry, LogLevel}, + source::SourceCodeAnalyzer, +}; + +use crate::ai::analyzer::LocalAiLogAnalyzer; + +pub struct LogcatAnalyzer { + pub entries: Vec, + regex: Regex, + pub source_analyzer: Option, +} + +impl LogcatAnalyzer { + pub fn new() -> Result> { + let regex = Regex::new( + r"^(\d{2}-\d{2}\s+\d{2}:\d{2}:\d{2}\.\d{3})\s+(\d+)\s+(\d+)\s+([VDIWEF])\s+([^:]+):\s*(.*)$", + )?; + + Ok(LogcatAnalyzer { + entries: Vec::new(), + regex, + source_analyzer: None, + }) + } + + pub fn with_source_code>( + source_path: P, + ) -> Result> { + let mut analyzer = Self::new()?; + analyzer.source_analyzer = Some(SourceCodeAnalyzer::new(source_path)?); + Ok(analyzer) + } + + pub fn parse_file>( + &mut self, + path: P, + ) -> Result<(), Box> { + use std::io::Read; + + let mut file = File::open(path.as_ref())?; + let mut buffer = Vec::new(); + file.read_to_end(&mut buffer)?; + + // Convert bytes to string, replacing invalid UTF-8 sequences + let content = String::from_utf8_lossy(&buffer); + + let mut line_count = 0; + let mut parsed_count = 0; + let mut error_count = 0; + + for line in content.lines() { + line_count += 1; + println!("{}: {}", line_count, line); + + // Skip empty lines and lines that are clearly malformed + if line.trim().is_empty() { + continue; + } + + // Try to parse the line, but don't fail if it's malformed + match self.try_parse_line(line) { + Ok(Some(entry)) => { + self.entries.push(entry); + parsed_count += 1; + } + Ok(None) => { + // Line didn't match expected format, but that's okay + continue; + } + Err(e) => { + error_count += 1; + if error_count <= 5 { + eprintln!( + "Warning: Failed to parse line {}: {} (line: {})", + line_count, + e, + line.chars().take(100).collect::() + ); + } + + // Still create an entry for unparsed lines if they seem like logs + if line.len() > 10 + && (line.contains(" I ") + || line.contains(" E ") + || line.contains(" W ") + || line.contains(" D ") + || line.contains(" V ") + || line.contains(" F ")) + { + self.entries.push(LogEntry { + timestamp: None, + pid: None, + tid: None, + level: LogLevel::Unknown("?".to_string()), + tag: "PARSE_ERROR".to_string(), + message: line.to_string(), + raw_line: line.to_string(), + source_location: None, + }); + } + } + } + } + + if error_count > 5 { + eprintln!( + "... and {} more parsing errors (showing first 5)", + error_count - 5 + ); + } + + println!( + "Parsed {} lines: {} successfully parsed, {} errors, {} total entries", + line_count, + parsed_count, + error_count, + self.entries.len() + ); + + Ok(()) + } + + fn try_parse_line(&self, line: &str) -> Result, Box> { + // First, clean the line of any problematic characters + let cleaned_line = self.clean_line(line); + + if let Some(captures) = self.regex.captures(&cleaned_line) { + let timestamp_str = captures.get(1).ok_or("Missing timestamp")?.as_str(); + let pid_str = captures.get(2).ok_or("Missing PID")?.as_str(); + let tid_str = captures.get(3).ok_or("Missing TID")?.as_str(); + let level_str = captures.get(4).ok_or("Missing log level")?.as_str(); + let tag = captures + .get(5) + .ok_or("Missing tag")? + .as_str() + .trim() + .to_string(); + let message = captures + .get(6) + .ok_or("Missing message")? + .as_str() + .to_string(); + + // Parse timestamp with error handling + let timestamp = match NaiveDateTime::parse_from_str( + &format!("2024-{}", timestamp_str), + "%Y-%m-%d %H:%M:%S%.3f", + ) { + Ok(ts) => Some(ts), + Err(_) => { + // Try alternative timestamp formats + self.parse_alternative_timestamp(timestamp_str) + } + }; + + // Parse PID and TID with error handling + let pid = pid_str.parse().ok(); + let tid = tid_str.parse().ok(); + let level = LogLevel::from_str(level_str); + + // Try to find source code location if source analyzer is available + let source_location = if let Some(source_analyzer) = &self.source_analyzer { + source_analyzer.find_log_source(&tag, &message) + } else { + None + }; + + Ok(Some(LogEntry { + timestamp, + pid, + tid, + level, + tag, + message, + raw_line: line.to_string(), + source_location, + })) + } else { + // Try alternative parsing patterns for non-standard log formats + self.try_alternative_parsing(&cleaned_line) + } + } + + fn clean_line(&self, line: &str) -> String { + // Remove or replace problematic characters + line.chars() + .filter(|c| c.is_ascii() || c.is_alphanumeric() || " :.-/()[]{}".contains(*c)) + .collect::() + .replace('\0', "") // Remove null bytes + .replace('\r', "") // Remove carriage returns + } + + fn parse_alternative_timestamp(&self, timestamp_str: &str) -> Option { + // Try various timestamp formats commonly found in Android logs + let formats = vec![ + "%m-%d %H:%M:%S%.3f", + "%Y-%m-%d %H:%M:%S%.3f", + "%m-%d %H:%M:%S", + "%H:%M:%S%.3f", + "%H:%M:%S", + ]; + + for format in formats { + if let Ok(ts) = NaiveDateTime::parse_from_str( + &if format.starts_with("%Y") { + timestamp_str.to_string() + } else { + format!("2024-{}", timestamp_str) + }, + format, + ) { + return Some(ts); + } + } + + None + } + + fn try_alternative_parsing( + &self, + line: &str, + ) -> Result, Box> { + // Try to parse common alternative log formats + + // Simple format: LEVEL/TAG: message + if let Some(caps) = Regex::new(r"^([VDIWEF])/([^:]+):\s*(.*)$")?.captures(line) { + let level = LogLevel::from_str(caps.get(1).unwrap().as_str()); + let tag = caps.get(2).unwrap().as_str().trim().to_string(); + let message = caps.get(3).unwrap().as_str().to_string(); + + return Ok(Some(LogEntry { + timestamp: None, + pid: None, + tid: None, + level, + tag, + message, + raw_line: line.to_string(), + source_location: None, + })); + } + + // System.out format: message (no level/tag) + if line.len() > 5 && !line.starts_with("--") && !line.starts_with("==") { + return Ok(Some(LogEntry { + timestamp: None, + pid: None, + tid: None, + level: LogLevel::Info, // Assume info level for unknown format + tag: "UNKNOWN".to_string(), + message: line.to_string(), + raw_line: line.to_string(), + source_location: None, + })); + } + + Ok(None) + } + + fn parse_line(&self, line: &str) -> Option { + if let Some(captures) = self.regex.captures(line) { + let timestamp_str = captures.get(1)?.as_str(); + let pid_str = captures.get(2)?.as_str(); + let tid_str = captures.get(3)?.as_str(); + let level_str = captures.get(4)?.as_str(); + let tag = captures.get(5)?.as_str().trim().to_string(); + let message = captures.get(6)?.as_str().to_string(); + + let timestamp = NaiveDateTime::parse_from_str( + &format!("2024-{}", timestamp_str), + "%Y-%m-%d %H:%M:%S%.3f", + ) + .ok(); + + let pid = pid_str.parse().ok(); + let tid = tid_str.parse().ok(); + let level = LogLevel::from_str(level_str); + + // Try to find source code location if source analyzer is available + let source_location = if let Some(source_analyzer) = &self.source_analyzer { + source_analyzer.find_log_source(&tag, &message) + } else { + None + }; + + Some(LogEntry { + timestamp, + pid, + tid, + level, + tag, + message, + raw_line: line.to_string(), + source_location, + }) + } else { + Some(LogEntry { + timestamp: None, + pid: None, + tid: None, + level: LogLevel::Unknown("?".to_string()), + tag: "UNPARSED".to_string(), + message: line.to_string(), + raw_line: line.to_string(), + source_location: None, + }) + } + } + + // Enhanced anomaly detection + pub fn detect_anomalies(&self) -> Vec { + let mut anomalies = Vec::new(); + + // Detect frequency spikes + anomalies.extend(self.detect_frequency_spikes()); + + // Detect unusual error patterns + anomalies.extend(self.detect_unusual_error_patterns()); + + // Detect potential memory leaks + anomalies.extend(self.detect_memory_issues()); + + // Detect performance degradation + anomalies.extend(self.detect_performance_issues()); + + // Detect crash loops + anomalies.extend(self.detect_crash_loops()); + + anomalies + } + + fn detect_frequency_spikes(&self) -> Vec { + let mut anomalies = Vec::new(); + let mut tag_frequencies: HashMap> = HashMap::new(); + + // Group entries by tag and collect indices + for (idx, entry) in self.entries.iter().enumerate() { + tag_frequencies + .entry(entry.tag.clone()) + .or_default() + .push(idx); + } + + // Detect tags with unusually high frequency + for (tag, indices) in tag_frequencies { + if indices.len() > 100 { + // Threshold for spike detection + let frequency_per_minute = if let (Some(first), Some(last)) = ( + self.entries.get(indices[0]).and_then(|e| e.timestamp), + self.entries + .get(*indices.last().unwrap()) + .and_then(|e| e.timestamp), + ) { + let duration = last.signed_duration_since(first).num_minutes().max(1); + indices.len() as f32 / duration as f32 + } else { + indices.len() as f32 + }; + + if frequency_per_minute > 10.0 { + anomalies.push(LogAnomaly { + anomaly_type: AnomalyType::FrequencySpike, + description: format!( + "High frequency logging from tag '{}': {:.1} entries/minute", + tag, frequency_per_minute + ), + entries: indices, + severity: (frequency_per_minute / 100.0).min(1.0), + }); + } + } + } + + anomalies + } + + fn detect_unusual_error_patterns(&self) -> Vec { + let mut anomalies = Vec::new(); + let mut error_patterns: HashMap> = HashMap::new(); + + // Collect error patterns + for (idx, entry) in self.entries.iter().enumerate() { + if matches!(entry.level, LogLevel::Error | LogLevel::Fatal) { + // Extract first few words as pattern + let pattern = entry + .message + .split_whitespace() + .take(5) + .collect::>() + .join(" "); + + error_patterns.entry(pattern).or_default().push(idx); + } + } + + // Find patterns that appear frequently + for (pattern, indices) in error_patterns { + if indices.len() > 5 { + anomalies.push(LogAnomaly { + anomaly_type: AnomalyType::UnusualErrorPattern, + description: format!( + "Recurring error pattern: '{}' ({} occurrences)", + pattern, + indices.len() + ), + entries: indices.clone(), + severity: (indices.clone().len() as f32 / 20.0).min(1.0), + }); + } + } + + anomalies + } + + fn detect_memory_issues(&self) -> Vec { + let mut anomalies = Vec::new(); + let memory_keywords = ["OutOfMemoryError", "GC_", "memory", "heap", "oom"]; + + let memory_entries: Vec = self + .entries + .iter() + .enumerate() + .filter(|(_, entry)| { + memory_keywords.iter().any(|keyword| { + entry + .message + .to_lowercase() + .contains(&keyword.to_lowercase()) + || entry.tag.to_lowercase().contains(&keyword.to_lowercase()) + }) + }) + .map(|(idx, _)| idx) + .collect(); + + if memory_entries.len() > 10 { + anomalies.push(LogAnomaly { + anomaly_type: AnomalyType::MemoryLeak, + description: format!( + "Potential memory issues detected: {} related entries", + memory_entries.len() + ), + entries: memory_entries, + severity: 0.8, + }); + } + + anomalies + } + + fn detect_performance_issues(&self) -> Vec { + let mut anomalies = Vec::new(); + let perf_keywords = ["slow", "timeout", "ANR", "blocked", "lag", "performance"]; + + let perf_entries: Vec = self + .entries + .iter() + .enumerate() + .filter(|(_, entry)| { + perf_keywords.iter().any(|keyword| { + entry + .message + .to_lowercase() + .contains(&keyword.to_lowercase()) + }) + }) + .map(|(idx, _)| idx) + .collect(); + + if perf_entries.len() > 5 { + anomalies.push(LogAnomaly { + anomaly_type: AnomalyType::PerformanceDegradation, + description: format!( + "Performance issues detected: {} related entries", + perf_entries.len() + ), + entries: perf_entries, + severity: 0.7, + }); + } + + anomalies + } + + fn detect_crash_loops(&self) -> Vec { + let mut anomalies = Vec::new(); + let crashes = self.find_crashes(); + + if crashes.len() > 3 { + // Check if crashes are happening in quick succession + let mut crash_times = Vec::new(); + for crash in &crashes { + if let Some(timestamp) = crash.timestamp { + crash_times.push(timestamp); + } + } + + crash_times.sort(); + let mut quick_crashes = 0; + + for window in crash_times.windows(2) { + if let [first, second] = window { + if second.signed_duration_since(*first) < Duration::minutes(5) { + quick_crashes += 1; + } + } + } + + if quick_crashes > 2 { + let crash_indices: Vec = crashes + .iter() + .map(|crash| { + self.entries + .iter() + .position(|e| e.raw_line == crash.raw_line) + .unwrap_or(0) + }) + .collect(); + + anomalies.push(LogAnomaly { + anomaly_type: AnomalyType::CrashLoop, + description: format!( + "Potential crash loop detected: {} crashes in quick succession", + quick_crashes + ), + entries: crash_indices, + severity: 0.9, + }); + } + } + + anomalies + } + + // Existing methods remain the same + pub fn filter_by_level(&self, min_level: LogLevel) -> Vec<&LogEntry> { + let min_priority = min_level.priority(); + self.entries + .iter() + .filter(|entry| entry.level.priority() >= min_priority) + .collect() + } + + pub fn filter_by_tag(&self, tag: &str) -> Vec<&LogEntry> { + self.entries + .iter() + .filter(|entry| entry.tag.contains(tag)) + .collect() + } + + pub fn filter_by_message(&self, pattern: &str) -> Vec<&LogEntry> { + self.entries + .iter() + .filter(|entry| entry.message.contains(pattern)) + .collect() + } + + pub fn get_error_summary(&self) -> HashMap { + let mut summary = HashMap::new(); + + for entry in &self.entries { + if matches!(entry.level, LogLevel::Error | LogLevel::Fatal) { + *summary.entry(entry.tag.clone()).or_insert(0) += 1; + } + } + + summary + } + + pub fn get_tag_statistics(&self) -> HashMap> { + let mut stats = HashMap::new(); + + for entry in &self.entries { + let tag_stats = stats.entry(entry.tag.clone()).or_insert_with(HashMap::new); + let level_name = format!("{:?}", entry.level); + *tag_stats.entry(level_name).or_insert(0) += 1; + } + + stats + } + + pub fn find_crashes(&self) -> Vec<&LogEntry> { + self.entries + .iter() + .filter(|entry| { + entry.message.to_lowercase().contains("crash") + || entry.message.to_lowercase().contains("exception") + || entry.message.to_lowercase().contains("fatal") + || entry.tag.to_lowercase().contains("crash") + || entry.message.contains("FATAL EXCEPTION") + || entry.message.contains("AndroidRuntime") + }) + .collect() + } + + pub fn get_total_entries(&self) -> usize { + self.entries.len() + } + + pub async fn print_ai_analysis(&self, ai_analyzer: &LocalAiLogAnalyzer) { + println!("\n=== AI-Powered Analysis ==="); + + let all_entries: Vec<&LogEntry> = self.entries.iter().collect(); + match ai_analyzer.analyze_logs(self, &all_entries).await { + Ok(insights) => { + for insight in insights { + println!( + "\n🔍 {} Analysis (Confidence: {:.1}%)", + insight.category.replace("_", " ").to_uppercase(), + insight.confidence * 100.0 + ); + println!(" Severity: {}", insight.severity.to_uppercase()); + println!(" Issue: {}", insight.description); + println!(" Recommendation: {}", insight.recommendation); + } + } + Err(e) => println!("AI analysis failed: {}", e), + } + } + + pub fn print_summary(&self) { + println!("=== Logcat Analysis Summary ==="); + println!("Total log entries: {}", self.get_total_entries()); + + // Level distribution + let mut level_counts = HashMap::new(); + for entry in &self.entries { + let level_name = format!("{:?}", entry.level); + *level_counts.entry(level_name).or_insert(0) += 1; + } + + println!("\nLog Level Distribution:"); + for (level, count) in level_counts { + println!(" {}: {}", level, count); + } + + // Error summary + let errors = self.get_error_summary(); + if !errors.is_empty() { + println!("\nError Summary (by tag):"); + let mut error_vec: Vec<_> = errors.iter().collect(); + error_vec.sort_by(|a, b| b.1.cmp(a.1)); + for (tag, count) in error_vec { + println!(" {}: {} errors", tag, count); + } + } + + // Anomaly detection + let anomalies = self.detect_anomalies(); + if !anomalies.is_empty() { + println!("\n🚨 Anomalies Detected:"); + for anomaly in &anomalies { + println!( + " {:?} (Severity: {:.1}): {}", + anomaly.anomaly_type, + anomaly.severity * 100.0, + anomaly.description + ); + } + } + + // Crash detection + let crashes = self.find_crashes(); + if !crashes.is_empty() { + println!("\n💥 Potential Crashes Found: {}", crashes.len()); + for crash in crashes.iter().take(5) { + println!( + " [{}] {}: {}", + format!("{:?}", crash.level), + crash.tag, + crash.message.chars().take(80).collect::() + ); + } + } + } +} diff --git a/src/logcat/mod.rs b/src/logcat/mod.rs new file mode 100644 index 0000000..6aa0e1b --- /dev/null +++ b/src/logcat/mod.rs @@ -0,0 +1 @@ +pub(crate) mod logcat_analyzer; diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d09c590 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,185 @@ +use crate::ai::analyzer::LocalAiLogAnalyzer; +use crate::logcat::logcat_analyzer::LogcatAnalyzer; +use crate::model::log_entry::LogEntry; +use crate::model::log_entry::LogLevel; +use clap::{Arg, Command}; +use tokio; + +mod ai; +mod logcat; +mod model; + +#[tokio::main] +async fn main() -> Result<(), Box> { + let matches = Command::new("AI-Powered Logcat Analyzer") + .version("2.0") + .author("Your Name") + .about("Analyzes Android logcat files with AI insights") + .arg( + Arg::new("file") + .short('f') + .long("file") + .value_name("FILE") + .help("Logcat file to analyze") + .required(true), + ) + .arg( + Arg::new("level") + .short('l') + .long("level") + .value_name("LEVEL") + .help("Minimum log level (V, D, I, W, E, F)"), + ) + .arg( + Arg::new("tag") + .short('t') + .long("tag") + .value_name("TAG") + .help("Filter by tag"), + ) + .arg( + Arg::new("message") + .short('m') + .long("message") + .value_name("PATTERN") + .help("Filter by message content"), + ) + .arg( + Arg::new("crashes") + .short('c') + .long("crashes") + .help("Show only potential crashes") + .action(clap::ArgAction::SetTrue), + ) + .arg( + Arg::new("ai") + .long("ai") + .help("Enable AI-powered analysis") + .action(clap::ArgAction::SetTrue), + ) + .arg( + Arg::new("ollama-host") + .long("ollama-host") + .value_name("HOST") + .help("Ollama server host (default: http://localhost:11434)"), + ) + .arg( + Arg::new("model") + .long("model") + .value_name("MODEL") + .help("Ollama model name (default: llama3.1)"), + ) + .arg( + Arg::new("source") + .short('s') + .long("source") + .value_name("SOURCE_DIR") + .help("Android source code directory for correlation analysis"), + ) + .get_matches(); + + let file_path = matches.get_one::("file").unwrap(); + + // Initialize analyzer with or without source code + let mut analyzer = if let Some(source_dir) = matches.get_one::("source") { + println!( + "Initializing with source code analysis from: {}", + source_dir + ); + LogcatAnalyzer::with_source_code(source_dir)? + } else { + LogcatAnalyzer::new()? + }; + + println!("Parsing logcat file: {}", file_path); + analyzer.parse_file(file_path)?; + + // Apply filters + let mut filtered_entries: Vec<&LogEntry> = analyzer.entries.iter().collect(); + + if let Some(level_str) = matches.get_one::("level") { + let level = LogLevel::from_str(level_str); + filtered_entries = analyzer.filter_by_level(level); + } + + if let Some(tag) = matches.get_one::("tag") { + filtered_entries = analyzer.filter_by_tag(tag); + } + + if let Some(pattern) = matches.get_one::("message") { + filtered_entries = analyzer.filter_by_message(pattern); + } + + if matches.get_flag("crashes") { + filtered_entries = analyzer.find_crashes(); + } + + // Print summary with enhanced analysis + analyzer.print_summary(); + + // AI Analysis + if matches.get_flag("ai") { + let ollama_host = matches + .get_one::("ollama-host") + .cloned() + .or_else(|| std::env::var("OLLAMA_HOST").ok()); + + let model_name = matches + .get_one::("model") + .cloned() + .or_else(|| std::env::var("OLLAMA_MODEL").ok()); + + let ai_analyzer = LocalAiLogAnalyzer::new(ollama_host, model_name); + analyzer.print_ai_analysis(&ai_analyzer).await; + } + + // Print filtered results with source info + if !filtered_entries.is_empty() && !matches.get_flag("ai") { + println!( + "\n=== Filtered Results ({} entries) ===", + filtered_entries.len() + ); + for entry in filtered_entries.iter().take(20) { + if let Some(timestamp) = &entry.timestamp { + print!("{} ", timestamp.format("%m-%d %H:%M:%S%.3f")); + } + if let Some(pid) = entry.pid { + print!("{:5} ", pid); + } + + // Include source location if available + let source_info = if let Some(source) = &entry.source_location { + format!( + " [{}:{}]", + source.file_path, + source.line_number.unwrap_or(0) + ) + } else { + String::new() + }; + + println!( + "[{:?}] {}: {}{}", + entry.level, entry.tag, entry.message, source_info + ); + + // Show code context for errors + if matches!(entry.level, LogLevel::Error | LogLevel::Fatal) { + if let Some(source) = &entry.source_location { + if !source.code_context.is_empty() { + println!(" Code context:"); + for (i, line) in source.code_context.iter().take(3).enumerate() { + println!(" {}", line); + } + } + } + } + } + + if filtered_entries.len() > 20 { + println!("... and {} more entries", filtered_entries.len() - 20); + } + } + + Ok(()) +} diff --git a/src/model/ai.rs b/src/model/ai.rs new file mode 100644 index 0000000..7a2bf4d --- /dev/null +++ b/src/model/ai.rs @@ -0,0 +1,39 @@ +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Serialize, Deserialize)] +pub struct AIAnalysisRequest { + pub log_summary: String, + pub error_patterns: Vec, + pub crash_entries: Vec, + pub anomalies: Vec, + pub source_code_context: Vec, + pub code_quality_issues: Vec, + pub context: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct AIInsight { + pub category: String, + pub severity: String, + pub description: String, + pub recommendation: String, + pub confidence: f32, +} + +#[derive(Debug)] +pub struct LogAnomaly { + pub anomaly_type: AnomalyType, + pub description: String, + pub entries: Vec, // indices into the log entries + pub severity: f32, +} + +#[derive(Debug)] +pub enum AnomalyType { + FrequencySpike, + UnusualErrorPattern, + MemoryLeak, + PerformanceDegradation, + CrashLoop, + SuspiciousActivity, +} diff --git a/src/model/log_entry.rs b/src/model/log_entry.rs new file mode 100644 index 0000000..f1cb052 --- /dev/null +++ b/src/model/log_entry.rs @@ -0,0 +1,51 @@ +use crate::model::source::SourceLocation; +use chrono::NaiveDateTime; + +#[derive(Debug, Clone)] +pub struct LogEntry { + pub timestamp: Option, + pub pid: Option, + pub tid: Option, + pub level: LogLevel, + pub tag: String, + pub message: String, + pub raw_line: String, + pub source_location: Option, +} + +#[derive(Debug, Clone, PartialEq)] +pub enum LogLevel { + Verbose, + Debug, + Info, + Warning, + Error, + Fatal, + Unknown(String), +} + +impl LogLevel { + pub fn from_str(s: &str) -> Self { + match s.to_uppercase().as_str() { + "V" => LogLevel::Verbose, + "D" => LogLevel::Debug, + "I" => LogLevel::Info, + "W" => LogLevel::Warning, + "E" => LogLevel::Error, + "F" => LogLevel::Fatal, + _ => LogLevel::Unknown(s.to_string()), + } + } + + pub fn priority(&self) -> u8 { + match self { + LogLevel::Verbose => 2, + LogLevel::Debug => 3, + LogLevel::Info => 4, + LogLevel::Warning => 5, + LogLevel::Error => 6, + LogLevel::Fatal => 7, + LogLevel::Unknown(_) => 0, + } + } +} diff --git a/src/model/mod.rs b/src/model/mod.rs new file mode 100644 index 0000000..08983b4 --- /dev/null +++ b/src/model/mod.rs @@ -0,0 +1,3 @@ +pub mod ai; +pub mod log_entry; +pub mod source; diff --git a/src/model/source.rs b/src/model/source.rs new file mode 100644 index 0000000..3f60946 --- /dev/null +++ b/src/model/source.rs @@ -0,0 +1,320 @@ +use crate::model::log_entry::LogLevel; +use std::{ + collections::{HashMap, HashSet}, + fs::read_to_string, + path::{Path, PathBuf}, +}; + +use regex::Regex; +use walkdir::WalkDir; + +use crate::model::log_entry::LogEntry; + +#[derive(Debug, Clone)] +pub struct SourceLocation { + pub file_path: String, + pub line_number: Option, + pub method_name: Option, + pub class_name: Option, + pub code_context: Vec, +} + +pub struct SourceCodeAnalyzer { + pub source_root: PathBuf, + pub java_files: HashMap, + pub kotlin_files: HashMap, + pub log_patterns: Vec, +} + +impl SourceCodeAnalyzer { + pub fn new>(source_root: P) -> Result> { + let mut analyzer = SourceCodeAnalyzer { + source_root: source_root.as_ref().to_path_buf(), + java_files: HashMap::new(), + kotlin_files: HashMap::new(), + log_patterns: Vec::new(), + }; + + analyzer.init_log_patterns()?; + analyzer.scan_source_files()?; + + Ok(analyzer) + } + + fn init_log_patterns(&mut self) -> Result<(), Box> { + let patterns = vec![ + r#"Log\.([dviwe])\s*\(\s*["']([^"']+)["']\s*,\s*["']([^"']+)["']\s*\)"#, // Log.d("TAG", "message") + r#"Log\.([dviwe])\s*\(\s*([A-Z_][A-Z0-9_]*)\s*,\s*["']([^"']+)["']\s*\)"#, // Log.d(TAG, "message") + r#"android\.util\.Log\.([dviwe])\s*\([^)]+\)"#, // android.util.Log.d(...) + r#"logger\.([dviwe])\s*\(\s*["']([^"']+)["']\s*\)"#, // logger.d("message") + r#"Log\.([dviwe])\s*\(\s*TAG\s*,\s*[^)]+\)"#, // Log.d(TAG, variable) + r#"System\.out\.println\s*\(\s*["']([^"']+)["']\s*\)"#, // System.out.println("message") + ]; + + for pattern in patterns { + self.log_patterns.push(Regex::new(pattern)?); + } + + Ok(()) + } + + fn scan_source_files(&mut self) -> Result<(), Box> { + for entry in WalkDir::new(&self.source_root) { + let entry = entry?; + let path = entry.path(); + + if path.is_file() { + if let Some(extension) = path.extension() { + match extension.to_str() { + Some("java") => { + if let Ok(content) = read_to_string(path) { + if let Some(filename) = path.file_name().and_then(|n| n.to_str()) { + self.java_files.insert(filename.to_string(), content); + } + } + } + Some("kt") => { + if let Ok(content) = read_to_string(path) { + if let Some(filename) = path.file_name().and_then(|n| n.to_str()) { + self.kotlin_files.insert(filename.to_string(), content); + } + } + } + _ => {} + } + } + } + } + + Ok(()) + } + + pub fn find_log_source(&self, tag: &str, message: &str) -> Option { + if let Some(location) = self.search_in_files(&self.java_files, tag, message) { + return Some(location); + } + + self.search_in_files(&self.kotlin_files, tag, message) + } + + fn search_in_files( + &self, + files: &HashMap, + tag: &str, + message: &str, + ) -> Option { + for (filename, content) in files { + if let Some(location) = self.search_in_file(filename, content, tag, message) { + return Some(location); + } + } + None + } + + fn search_in_file( + &self, + filename: &str, + content: &str, + tag: &str, + message: &str, + ) -> Option { + let lines: Vec<&str> = content.lines().collect(); + + for (line_idx, line) in lines.iter().enumerate() { + for pattern in &self.log_patterns { + if let Some(captures) = pattern.captures(line) { + let found_tag = captures.get(2).map(|m| m.as_str()).unwrap_or(""); + let found_message = captures.get(3).map(|m| m.as_str()).unwrap_or(""); + + if self.tags_match(tag, found_tag) && self.message_match(message, found_message) + { + let context = self.extract_code_context(&lines, line_idx); + let class_name = self.extract_class_name(content); + let method_name = self.extract_method_name(&lines, line_idx); + + return Some(SourceLocation { + file_path: filename.to_string(), + line_number: Some((line_idx + 1) as u32), + method_name, + class_name, + code_context: context, + }); + } + } + } + + if line.contains(&format!("\"{}\"", message)) + || line.contains(&format!("'{}'", message)) + { + let context = self.extract_code_context(&lines, line_idx); + let class_name = self.extract_class_name(content); + let method_name = self.extract_method_name(&lines, line_idx); + + return Some(SourceLocation { + file_path: filename.to_string(), + line_number: Some((line_idx + 1) as u32), + method_name, + class_name, + code_context: context, + }); + } + } + + None + } + + fn tags_match(&self, log_tag: &str, code_tag: &str) -> bool { + if log_tag == code_tag { + return true; + } + + if code_tag == "TAG" { + return true; + } + + log_tag.contains(code_tag) || code_tag.contains(log_tag) + } + + fn message_match(&self, log_message: &str, code_message: &str) -> bool { + if log_message == code_message { + return true; + } + + let log_words: HashSet<&str> = log_message.split_whitespace().collect(); + let code_words: HashSet<&str> = code_message.split_whitespace().collect(); + + let common_words = log_words.intersection(&code_words).count(); + let total_words = log_words.len().max(code_words.len()); + + if total_words > 0 { + let similarity = common_words as f32 / total_words as f32; + similarity > 0.6 + } else { + false + } + } + + fn extract_code_context(&self, lines: &[&str], center_line: usize) -> Vec { + let start = center_line.saturating_sub(3); + let end = (center_line + 4).min(lines.len()); + + lines[start..end] + .iter() + .enumerate() + .map(|(i, line)| { + let line_num = start + i + 1; + let marker = if start + i == center_line { + ">>>" + } else { + " " + }; + format!("{} {:3}: {}", marker, line_num, line.trim()) + }) + .collect() + } + + fn extract_class_name(&self, content: &str) -> Option { + let class_regex = Regex::new(r"(?:public\s+)?(?:class|interface)\s+(\w+)").ok()?; + class_regex + .captures(content) + .and_then(|caps| caps.get(1)) + .map(|m| m.as_str().to_string()) + } + + fn extract_method_name(&self, lines: &[&str], line_idx: usize) -> Option { + for i in (0..line_idx).rev() { + let line = lines[i].trim(); + let method_patterns = vec![ + Regex::new(r"(?:public|private|protected)?\s*(?:static\s+)?(?:\w+\s+)?(\w+)\s*\([^)]*\)\s*\{").ok()?, + Regex::new(r"fun\s+(\w+)\s*\([^)]*\)").ok()?, + ]; + + for pattern in method_patterns { + if let Some(captures) = pattern.captures(line) { + if let Some(method_name) = captures.get(1) { + return Some(method_name.as_str().to_string()); + } + } + } + + if line.contains("class ") || line.contains("interface ") { + break; + } + } + + None + } + + pub fn analyze_code_quality(&self, entries: &[&LogEntry]) -> Vec { + let mut issues = Vec::new(); + + // Analyze logging patterns + let mut log_frequency: HashMap = HashMap::new(); + let mut error_sources: HashMap = HashMap::new(); + + for entry in entries { + if let Some(source) = &entry.source_location { + *log_frequency.entry(source.file_path.clone()).or_insert(0) += 1; + + if matches!(entry.level, LogLevel::Error | LogLevel::Fatal) { + *error_sources.entry(source.file_path.clone()).or_insert(0) += 1; + } + } + } + + // Find files with excessive logging + for (file, count) in log_frequency { + if count > 50 { + issues.push(CodeQualityIssue { + issue_type: CodeIssueType::ExcessiveLogging, + file_path: file.clone(), + description: format!( + "File {} has {} log statements, consider reducing verbosity", + file, count + ), + severity: if count > 100 { "high" } else { "medium" }.to_string(), + recommendation: + "Review logging strategy and remove debug logs from production code" + .to_string(), + }); + } + } + + // Find files with many errors + for (file, count) in error_sources { + if count > 10 { + issues.push(CodeQualityIssue { + issue_type: CodeIssueType::ErrorProne, + file_path: file.clone(), + description: format!( + "File {} generates {} error logs, indicating potential issues", + file, count + ), + severity: "high".to_string(), + recommendation: "Review error handling and fix underlying causes of errors" + .to_string(), + }); + } + } + + issues + } +} + +#[derive(Debug)] +pub struct CodeQualityIssue { + pub issue_type: CodeIssueType, + pub file_path: String, + pub description: String, + pub severity: String, + pub recommendation: String, +} + +#[derive(Debug)] +pub enum CodeIssueType { + ExcessiveLogging, + ErrorProne, + PerformanceIssue, + SecurityIssue, + BadPractice, +}