mirror of
https://github.com/velopack/velopack.git
synced 2025-10-25 15:19:22 +00:00
Add some logging
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
#include <optional>
|
#include <optional>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include "Velopack.h"
|
#include "Velopack.hpp"
|
||||||
|
|
||||||
using namespace Velopack;
|
using namespace Velopack;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ fn main() {
|
|||||||
.with_crate(crate_dir)
|
.with_crate(crate_dir)
|
||||||
.with_documentation(true)
|
.with_documentation(true)
|
||||||
.with_language(cbindgen::Language::C)
|
.with_language(cbindgen::Language::C)
|
||||||
.with_autogen_warning("// === THIS FILE IS AUTO-GENERATED - DO NOT EDIT ===")
|
.with_autogen_warning("/* THIS FILE IS AUTO-GENERATED - DO NOT EDIT */")
|
||||||
.with_include_guard("VELOPACK_H")
|
.with_include_guard("VELOPACK_H")
|
||||||
.with_cpp_compat(true)
|
.with_cpp_compat(true)
|
||||||
.with_include_version(true)
|
.with_include_version(true)
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
/* Generated with cbindgen:0.27.0 */
|
/* Generated with cbindgen:0.27.0 */
|
||||||
|
|
||||||
// === THIS FILE IS AUTO-GENERATED - DO NOT EDIT ===
|
/* THIS FILE IS AUTO-GENERATED - DO NOT EDIT */
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|||||||
@@ -200,6 +200,7 @@ static inline char** to_cstring_array(const std::vector<std::string>& vec) {
|
|||||||
#else
|
#else
|
||||||
strcpy(result[i], vec[i].c_str()); // Copy string content
|
strcpy(result[i], vec[i].c_str()); // Copy string content
|
||||||
#endif
|
#endif
|
||||||
|
result[i][vec[i].size()] = '\0'; // Null-terminate the string
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -207,6 +208,7 @@ static inline char** to_cstring_array(const std::vector<std::string>& vec) {
|
|||||||
static inline void free_cstring_array(char** arr, size_t size) {
|
static inline void free_cstring_array(char** arr, size_t size) {
|
||||||
for (size_t i = 0; i < size; ++i) {
|
for (size_t i = 0; i < size; ++i) {
|
||||||
delete[] arr[i];
|
delete[] arr[i];
|
||||||
|
arr[i] = nullptr;
|
||||||
}
|
}
|
||||||
delete[] arr;
|
delete[] arr;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -356,6 +356,6 @@ impl UpdateManagerOpaque {
|
|||||||
|
|
||||||
impl Drop for UpdateManagerOpaque {
|
impl Drop for UpdateManagerOpaque {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
log::debug!("UpdateManagerOpaque dropped");
|
log::debug!("UpdateManagerOpaque freed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ pub fn c_to_velopacklocatorconfig_opt(obj: *mut vpkc_locator_config_t) -> Option
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn allocate_velopacklocatorconfig(dto: VelopackLocatorConfig, obj: *mut vpkc_locator_config_t) {
|
pub unsafe fn allocate_velopacklocatorconfig(dto: VelopackLocatorConfig, obj: *mut vpkc_locator_config_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_locator_config_t allocated");
|
||||||
allocate_pathbuf(dto.RootAppDir, &mut (*obj).RootAppDir);
|
allocate_pathbuf(dto.RootAppDir, &mut (*obj).RootAppDir);
|
||||||
allocate_pathbuf(dto.UpdateExePath, &mut (*obj).UpdateExePath);
|
allocate_pathbuf(dto.UpdateExePath, &mut (*obj).UpdateExePath);
|
||||||
allocate_pathbuf(dto.PackagesDir, &mut (*obj).PackagesDir);
|
allocate_pathbuf(dto.PackagesDir, &mut (*obj).PackagesDir);
|
||||||
@@ -153,6 +154,7 @@ pub unsafe fn allocate_velopacklocatorconfig(dto: VelopackLocatorConfig, obj: *m
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn free_velopacklocatorconfig(obj: *mut vpkc_locator_config_t) {
|
pub unsafe fn free_velopacklocatorconfig(obj: *mut vpkc_locator_config_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_locator_config_t freed");
|
||||||
free_pathbuf(&mut (*obj).RootAppDir);
|
free_pathbuf(&mut (*obj).RootAppDir);
|
||||||
free_pathbuf(&mut (*obj).UpdateExePath);
|
free_pathbuf(&mut (*obj).UpdateExePath);
|
||||||
free_pathbuf(&mut (*obj).PackagesDir);
|
free_pathbuf(&mut (*obj).PackagesDir);
|
||||||
@@ -208,6 +210,7 @@ pub fn c_to_velopackasset_opt(obj: *mut vpkc_asset_t) -> Option<VelopackAsset> {
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn allocate_velopackasset(dto: VelopackAsset, obj: *mut vpkc_asset_t) {
|
pub unsafe fn allocate_velopackasset(dto: VelopackAsset, obj: *mut vpkc_asset_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_asset_t allocated");
|
||||||
allocate_string(dto.PackageId, &mut (*obj).PackageId);
|
allocate_string(dto.PackageId, &mut (*obj).PackageId);
|
||||||
allocate_string(dto.Version, &mut (*obj).Version);
|
allocate_string(dto.Version, &mut (*obj).Version);
|
||||||
allocate_string(dto.Type, &mut (*obj).Type);
|
allocate_string(dto.Type, &mut (*obj).Type);
|
||||||
@@ -222,6 +225,7 @@ pub unsafe fn allocate_velopackasset(dto: VelopackAsset, obj: *mut vpkc_asset_t)
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn free_velopackasset(obj: *mut vpkc_asset_t) {
|
pub unsafe fn free_velopackasset(obj: *mut vpkc_asset_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_asset_t freed");
|
||||||
free_string(&mut (*obj).PackageId);
|
free_string(&mut (*obj).PackageId);
|
||||||
free_string(&mut (*obj).Version);
|
free_string(&mut (*obj).Version);
|
||||||
free_string(&mut (*obj).Type);
|
free_string(&mut (*obj).Type);
|
||||||
@@ -261,6 +265,7 @@ pub fn c_to_updateinfo_opt(obj: *mut vpkc_update_info_t) -> Option<UpdateInfo> {
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn allocate_updateinfo(dto: UpdateInfo, obj: *mut vpkc_update_info_t) {
|
pub unsafe fn allocate_updateinfo(dto: UpdateInfo, obj: *mut vpkc_update_info_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_update_info_t allocated");
|
||||||
allocate_velopackasset(dto.TargetFullRelease, &mut (*obj).TargetFullRelease);
|
allocate_velopackasset(dto.TargetFullRelease, &mut (*obj).TargetFullRelease);
|
||||||
(*obj).IsDowngrade = dto.IsDowngrade;
|
(*obj).IsDowngrade = dto.IsDowngrade;
|
||||||
}
|
}
|
||||||
@@ -268,6 +273,7 @@ pub unsafe fn allocate_updateinfo(dto: UpdateInfo, obj: *mut vpkc_update_info_t)
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn free_updateinfo(obj: *mut vpkc_update_info_t) {
|
pub unsafe fn free_updateinfo(obj: *mut vpkc_update_info_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_update_info_t freed");
|
||||||
free_velopackasset(&mut (*obj).TargetFullRelease);
|
free_velopackasset(&mut (*obj).TargetFullRelease);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -307,6 +313,7 @@ pub fn c_to_updateoptions_opt(obj: *mut vpkc_update_options_t) -> Option<UpdateO
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn allocate_updateoptions(dto: UpdateOptions, obj: *mut vpkc_update_options_t) {
|
pub unsafe fn allocate_updateoptions(dto: UpdateOptions, obj: *mut vpkc_update_options_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_update_options_t allocated");
|
||||||
(*obj).AllowVersionDowngrade = dto.AllowVersionDowngrade;
|
(*obj).AllowVersionDowngrade = dto.AllowVersionDowngrade;
|
||||||
allocate_string_opt(dto.ExplicitChannel, &mut (*obj).ExplicitChannel);
|
allocate_string_opt(dto.ExplicitChannel, &mut (*obj).ExplicitChannel);
|
||||||
}
|
}
|
||||||
@@ -314,6 +321,7 @@ pub unsafe fn allocate_updateoptions(dto: UpdateOptions, obj: *mut vpkc_update_o
|
|||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
pub unsafe fn free_updateoptions(obj: *mut vpkc_update_options_t) {
|
pub unsafe fn free_updateoptions(obj: *mut vpkc_update_options_t) {
|
||||||
if obj.is_null() { return; }
|
if obj.is_null() { return; }
|
||||||
|
log::debug!("vpkc_update_options_t freed");
|
||||||
free_string(&mut (*obj).ExplicitChannel);
|
free_string(&mut (*obj).ExplicitChannel);
|
||||||
}
|
}
|
||||||
// !! AUTO-GENERATED-END RUST_TYPES
|
// !! AUTO-GENERATED-END RUST_TYPES
|
||||||
|
|||||||
@@ -99,6 +99,7 @@
|
|||||||
sb.AppendLine($"pub unsafe fn allocate_{rs.Name.ToLower()}(dto: {rs.Name}, obj: *mut {cName}) {{");
|
sb.AppendLine($"pub unsafe fn allocate_{rs.Name.ToLower()}(dto: {rs.Name}, obj: *mut {cName}) {{");
|
||||||
using (sb.Indent()) {
|
using (sb.Indent()) {
|
||||||
sb.AppendLine("if obj.is_null() { return; }");
|
sb.AppendLine("if obj.is_null() { return; }");
|
||||||
|
sb.AppendLine($"log::debug!(\"{cName} allocated\");");
|
||||||
foreach (var field in rs.Fields) {
|
foreach (var field in rs.Fields) {
|
||||||
if (field.Optional || field.Type == "PathBuf" || field.Type == "String" || nameMap.ContainsKey(field.Type)) {
|
if (field.Optional || field.Type == "PathBuf" || field.Type == "String" || nameMap.ContainsKey(field.Type)) {
|
||||||
sb.AppendLine($"allocate_{field.Type.ToLower()}{(field.Optional ? "_opt": "")}(dto.{field.Name}, &mut (*obj).{field.Name});");
|
sb.AppendLine($"allocate_{field.Type.ToLower()}{(field.Optional ? "_opt": "")}(dto.{field.Name}, &mut (*obj).{field.Name});");
|
||||||
@@ -114,6 +115,7 @@
|
|||||||
sb.AppendLine($"pub unsafe fn free_{rs.Name.ToLower()}(obj: *mut {cName}) {{");
|
sb.AppendLine($"pub unsafe fn free_{rs.Name.ToLower()}(obj: *mut {cName}) {{");
|
||||||
using (sb.Indent()) {
|
using (sb.Indent()) {
|
||||||
sb.AppendLine("if obj.is_null() { return; }");
|
sb.AppendLine("if obj.is_null() { return; }");
|
||||||
|
sb.AppendLine($"log::debug!(\"{cName} freed\");");
|
||||||
foreach (var field in rs.Fields) {
|
foreach (var field in rs.Fields) {
|
||||||
if (field.Optional || field.Type == "PathBuf" || field.Type == "String" || nameMap.ContainsKey(field.Type)) {
|
if (field.Optional || field.Type == "PathBuf" || field.Type == "String" || nameMap.ContainsKey(field.Type)) {
|
||||||
sb.AppendLine($"free_{field.Type.ToLower()}(&mut (*obj).{field.Name});");
|
sb.AppendLine($"free_{field.Type.ToLower()}(&mut (*obj).{field.Name});");
|
||||||
|
|||||||
Reference in New Issue
Block a user