{"id":15198720,"url":"https://github.com/sofish/log2json","last_synced_at":"2025-07-27T03:33:35.250Z","repository":{"id":143449394,"uuid":"46185333","full_name":"sofish/log2json","owner":"sofish","description":"transform nginx log to json","archived":false,"fork":false,"pushed_at":"2015-11-27T06:43:30.000Z","size":25,"stargazers_count":9,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-26T04:49:05.084Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/sofish.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":"2015-11-14T17:51:47.000Z","updated_at":"2020-12-29T05:33:52.000Z","dependencies_parsed_at":"2023-03-18T14:16:59.911Z","dependency_job_id":null,"html_url":"https://github.com/sofish/log2json","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/sofish/log2json","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofish%2Flog2json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofish%2Flog2json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofish%2Flog2json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofish%2Flog2json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sofish","download_url":"https://codeload.github.com/sofish/log2json/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sofish%2Flog2json/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267294180,"owners_count":24065343,"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","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-09-28T01:40:24.846Z","updated_at":"2025-07-27T03:33:35.221Z","avatar_url":"https://github.com/sofish.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![](https://travis-ci.org/sofish/log2json.svg)\n\n# Log2JSON\n\nLog2JSON is a small lib that allows you to transform nginx/apache/whatever\nlogs to JSON.\n\nInstall it will npm / cnpm:\n\n```ruby\n$ npm install log2json\n```\n\n## Usage\n\nRun it like:\n\n```js\nvar log2json = require('log2json');\n\nlog2json(configure, ret =\u003e {\n  if(!ret) return console.log('the file is empty');\n  console.log('JSON is generated: %s', ret);\n});\n```\n\nFollow the codes below to generate the `configure` object.\n\n```js\nvar path = require('path');\n\n\nvar separator = '•-•';                          // separator of the log\nvar src = path.join(__dirname, './log');        // path of the log\nvar dist = path.join(__dirname, './log.json');  // the generated JSON file\nvar removeSrc = true;                           // remove the log when JSON is\n                                                //  generated, by default is true\nvar map = [                                     // map the fields with keys\n\n  'fieldName2',             // 1. {string} name to the filed\n  fn2TransformData,         // 2. a custom function to transform the field\n                            //    should return an object {name, value}\n  'fieldName|number',       // 3. use built-in directive to\n                            //    transform the field\n  'fieldName|url',          //    built-in directives: number, url, array\n  'fieldName|array'         //    - `number` transform string to number\n                            //    - `array` transform 'a,b' to [\"a\",\"b\"]\n                            //    - `url` transform querystring to object\n                            //      'a=b\u0026c[]=d\u0026c[]=e' to {a:\"b\", c: [\"d\", \"e\"]}\n];\n\n// a transform function should return an object like {name, value}\nfunction fn2TransformData(input) {\n  var name = 'transformed';\n  var value = doSomethingWith(value);\n  return {name, value};\n}\n\n// what we need\nvar configure = {map, separator, src, dist, removeSrc};\n```\n\n## Test\n\nsimply run `npm test` on your favor terminal app.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofish%2Flog2json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsofish%2Flog2json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsofish%2Flog2json/lists"}