我正在尝试从Windows导出多个事件日志。一个事件日志的导出工作正常,但是当我尝试将它们合并时,我遇到了一个问题:文件大小合适,但事件数量却不够。 (log.evt的大小是日志文件的总和,但是当我使用事件查看器打开它时,事件数就是应用程序日志中的事件数)
void Msw::create_error_log() {
std::thread application_worker(create_application_log);
std::thread security_worker(create_security_log);
std::thread setup_worker(create_setup_log);
std::thread system_worker(create_system_log);
if (application_worker.joinable() && security_worker.joinable() && setup_worker.joinable() && system_worker.joinable()) {
application_worker.join();
security_worker.join();
setup_worker.join();
system_worker.join();
}
std::ifstream application_file("application-log.evt", std::ios_base::binary);
std::ifstream security_file("security-log.evt", std::ios_base::binary);
std::ifstream setup_file("setup-log.evt", std::ios_base::binary);
std::ifstream system_file("system-log.evt", std::ios_base::binary);
std::ofstream full_log("log.evt", std::ios_base::binary);
full_log << application_file.rdbuf() << setup_file.rdbuf() << system_file.rdbuf() << security_file.rdbuf();
}
void Msw::create_application_log() {
HANDLE handle = OpenEventLog(NULL, "Application");
BackupEventLog(handle, "application-log.evt");
}
void Msw::create_security_log() {
HANDLE handle = OpenEventLog(NULL, "Security");
BackupEventLog(handle, "security-log.evt");
}
void Msw::create_setup_log() {
HANDLE handle = OpenEventLog(NULL, "Setup");
BackupEventLog(handle, "setup-log.evt");
}
void Msw::create_system_log() {
HANDLE handle = OpenEventLog(NULL, "System");
BackupEventLog(handle, "system-log.evt");
}
答案 0 :(得分:0)
我已经设法通过使用EvtExportLog
来解决这个问题。
import turf from '@turf/turf'
import polyline from '@mapbox/polyline'
import shapefile from 'shapefile'
// The google routes api result
import data from './coords.js';
// The compete route polyline
const polydata = polyline.toGeoJSON(data.routes[0].overview_polyline.points);
async function fetchWorldData() {
let worldData = [];
try {
let overBorder = false;
// Load country borders shapeFile
const source = await shapefile.open("TM_WORLD_BORDERS-0.3.shp");
// Loop over all countries
while (true) {
// Read the source for a specific country
const result = await source.read();
if (result.done) break;
// Check if the trip will cross any borders, if they do, set overBorder to true
if (turf.lineIntersect(polydata, result.value.geometry).features.length !== 0) {
overBorder = true;
// Append intersected borders
worldData.push(result.value);
}
}
// Return a list with all the country data
return worldData;
} catch (e) {
console.log(e);
}
}
async function makePrediction() {
console.time("execution time");
// Object to returned
let countries = []
// When leaving a border you will intersect with it(1) You will then intersect with the next border (2) causing another intersect.
// This bool ignores the entering intersect.
let ignoreNextBorder = false;
try {
// Fetch the world data
let worldData = await fetchWorldData();
worldData.map(async border => {
// Store distance and duration per country
let distance = 0;
let duration = 0;
data.routes[0].legs[0].steps.map(async (step) => {
// Get the step starting point
let pt = turf.point([step.start_location.lng, step.start_location.lat]);
const pointInCountry = turf.booleanPointInPolygon(pt, border.geometry);
// Check if the step starting point is in the current country
if (pointInCountry) {
// Add the step distance to the total
distance += step.distance.value;
duration += step.duration.value;
}
});
countries[border.properties.NAME] = {
duration: duration,
distance: distance
}
});
console.timeEnd("execution time");
return countries;
} catch (e) {
console.log(e)
}
}
makePrediction().then(console.log);