Sha256: 8f2cb204afdbcf79f55f1628edbdc5a4424dd9884503c09538019733c769eed7
Contents?: true
Size: 479 Bytes
Versions: 14
Compression:
Stored size: 479 Bytes
Contents
require 'winevt' require 'rexml/document' @query = Winevt::EventLog::Query.new("Application", "*[System[(Level <= 3) and TimeCreated[timediff(@SystemTime) <= 86400000]]]") @query.each do |eventlog, message| doc = REXML::Document.new(eventlog) nodes = [] REXML::XPath.each(doc, "/Event/EventData/Data") do |node| nodes << node.text end message = message.gsub(/(%\d+)/, '\1$s') message = sprintf(message, *nodes) puts ({eventlog: eventlog, data: message}) end
Version data entries
14 entries across 14 versions & 1 rubygems