{"id":20269960,"url":"https://github.com/teliosdev/delog","last_synced_at":"2025-10-28T12:36:15.486Z","repository":{"id":6870225,"uuid":"8119225","full_name":"teliosdev/delog","owner":"teliosdev","description":"Parse and handle log files like there's no tomorrow.","archived":false,"fork":false,"pushed_at":"2013-02-16T18:45:04.000Z","size":204,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-10T23:38:59.616Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teliosdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-10T04:58:09.000Z","updated_at":"2014-03-27T02:09:10.000Z","dependencies_parsed_at":"2022-06-28T18:12:18.117Z","dependency_job_id":null,"html_url":"https://github.com/teliosdev/delog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/teliosdev/delog","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fdelog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fdelog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fdelog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fdelog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teliosdev","download_url":"https://codeload.github.com/teliosdev/delog/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teliosdev%2Fdelog/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260759780,"owners_count":23058482,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T12:28:12.866Z","updated_at":"2025-10-28T12:36:15.429Z","avatar_url":"https://github.com/teliosdev.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Delog \n\n[![Build Status](https://travis-ci.org/redjazz96/delog.png?branch=master)](https://travis-ci.org/redjazz96/delog) [![Code Climate](https://codeclimate.com/github/redjazz96/delog.png)](https://codeclimate.com/github/redjazz96/delog)\n\n`Delog` is a log file library.  It takes generic load files and using defined parser rules creates a reconstruction of the log in an accessible manner.  Have some code examples:\n\n```Ruby\nlog = Delog::Log.new(\"path/to/logfile\") # or, Delog::Log.new(some_io_object)\nlog.lines.each do |line|\n  line.class # =\u003e Delog::Line\nend\n\nlog.lines.first.type # =\u003e :comment (or some other value)\n```\n\nYou can also define your own parsers for the log files:\n\n```Ruby\n\n    class MyParser \u003c Delog::LineParser\n      build do\n        on %r{\\A\\*} do\n          set :type =\u003e :comment\n          stop\n        end\n        \n        on %r{\\AL} do\n          set :type =\u003e :log\n        end\n        \n        on %r{\n          \\AL\\s                   # The line starts with \"L\".  No idea why.\n          (?\u003cdatetime\u003e\n            [0-9]{2}\\/[0-9]{2}\\/[0-9]{4}\\s\\-\\s  # the date\n            [0-9]{2}\\:[0-9]{2}\\:[0-9]{2}        # the time\n          )\n        }x do |m|\n          set :time =\u003e m.datetime\n        end\n\n        # These two `on` calls do exactly the same thing.  I call the second one\n        # \"shorthand.\"  the `:stop =\u003e true` is the same as calling #stop, while\n        # any other key-value pair is sent to #set.\n        on %r{\\AW} do\n          set :type =\u003e :warning\n          stop\n        end\n\n        # _PLEASE_ note that the position of :stop =\u003e true in the hash matters.\n        # Any key-value pairs after :stop =\u003e true are ignored.\n        on %r{\\AW}, :type =\u003e :warning, :stop =\u003e true\n\n        # This one matches it to something other than the actual line.  This can\n        # be anything that responds to #match, but it's normally a string \n        # anyway.\n        on %r{\\AW} =\u003e something_predefined, :do =\u003e :something\n\n        # Here, if you've previously set :log to have a value, you can use it\n        # in a match.  But if you're not careful, you can accidentally cause\n        # name errors because +log+ isn't (and hasn't) been defined.  So use\n        # +get(:log)+ unless you're absolutely sure that +log+ always has a\n        # value.\n        on %r{\\AW (?\u003csomething\u003e.*?)} =\u003e log, :thing =\u003e d(:something)\n        \n        set :hello =\u003e :world, :foo =\u003e :bar\n        get(:hello)  # =\u003e :world\n        do_something # This calls the method we defined below.  Cool, eh?  This\n                     # means we can extract `on` calls to another method,\n                     # cleaning it up; or, you could set it up for another \n                     # (child) class to use.\n\n        # This calls the method #on_match defined below, outside of the block.\n        on %r{someone: (?\u003csomebody\u003e.*?);}, :on_match\n\n        get(:parsetime) # =\u003e about Time.now.utc\n        \n        stop # Completely optional.  This means that `on` blocks are ignored,\n             # and `set` calls are ignored.\n        stopped? # =\u003e true\n      end\n\n      def do_something\n        set :parsetime =\u003e Time.now.utc\n      end\n\n      def on_match(match)\n        set :something =\u003e match.somebody\n      end\n\n      # You have to add your methods to the whitelist that way only some methods\n      # are exposed to the parser.  This helps keep the namespace clean.\n      def_whitelist :do_something, :on_match\n    end\n\n    log = Delog::Log.new(\"path/to/log\", :parser =\u003e MyParser)\n    # assuming the first line is `* this is a comment`\n    log.lines.first.type # =\u003e :comment\n    log.lines.first[:parsetime] # =\u003e nil (`set` in do_something did nothing!)\n\n    log.lines.map do |line|\n      line.parsetime.class\n    end # =\u003e [NilClass, Time, ...]\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteliosdev%2Fdelog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteliosdev%2Fdelog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteliosdev%2Fdelog/lists"}