{"id":19133650,"url":"https://github.com/hashload/horse-logger-provider-logfile","last_synced_at":"2026-02-12T03:36:18.740Z","repository":{"id":45220838,"uuid":"335327656","full_name":"HashLoad/horse-logger-provider-logfile","owner":"HashLoad","description":"Horse Logger - Provider Logile","archived":false,"fork":false,"pushed_at":"2023-10-18T17:00:12.000Z","size":31,"stargazers_count":13,"open_issues_count":1,"forks_count":6,"subscribers_count":6,"default_branch":"main","last_synced_at":"2024-04-13T21:53:24.602Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Pascal","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/HashLoad.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,"governance":null}},"created_at":"2021-02-02T15:05:20.000Z","updated_at":"2023-11-06T12:10:13.000Z","dependencies_parsed_at":"2024-04-01T21:31:23.833Z","dependency_job_id":null,"html_url":"https://github.com/HashLoad/horse-logger-provider-logfile","commit_stats":{"total_commits":21,"total_committers":6,"mean_commits":3.5,"dds":"0.38095238095238093","last_synced_commit":"1e0b41a61f5397d2846dda58586f5daefcccaf5a"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-logger-provider-logfile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-logger-provider-logfile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-logger-provider-logfile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/HashLoad%2Fhorse-logger-provider-logfile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/HashLoad","download_url":"https://codeload.github.com/HashLoad/horse-logger-provider-logfile/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240214566,"owners_count":19766263,"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-09T06:23:18.468Z","updated_at":"2026-02-12T03:36:18.669Z","avatar_url":"https://github.com/HashLoad.png","language":"Pascal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# horse-logger-provider-logfile\n\u003cb\u003ehorse-logger-provider-logfile\u003c/b\u003e is an official \u003ca href=\"https://github.com/HashLoad/horse-logger\"\u003ehorse-logger\u003c/a\u003e middleware provider to save the logs of an API developed using the \u003ca href=\"https://github.com/HashLoad/horse\"\u003eHorse\u003c/a\u003e framework, in a physical file. We created a channel on Telegram for questions and support:\u003cbr\u003e\u003cbr\u003e\n\u003ca href=\"https://t.me/hashload\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/telegram-join%20channel-7289DA?style=flat-square\"\u003e\n\u003c/a\u003e\n\n## ⭕ Prerequisites\n[**horse-logger**](https://github.com/HashLoad/horse-logger) - Official middleware for logging in APIs developed with the Horse framework.\u003cbr\u003e\n[**horse-utils-clientip**](https://github.com/dliocode/horse-utils-clientip) - Capture the client's IP.\n\n*Obs: If you use Boss (dependency manager for Delphi), the jhonson will be installed automatically when installing horse-logger-provider-logfile.*\n\n## ⚙️ Installation\nInstallation is done using the [`boss install`](https://github.com/HashLoad/boss) command:\n``` sh\n$ boss install horse-logger-provider-logfile\n```\nIf you choose to install manually, simply add the following folders to your project, in *Project \u003e Options \u003e Resource Compiler \u003e Directories and Conditionals \u003e Include file search path*\n```\n../horse-logger-provider-logfile/src\n```\n\n## ✔️ Compatibility\nThis middleware is compatible with projects developed in:\n- [X] Delphi\n- [X] Lazarus\n\n## 🔠 Formatting\nYou can format the log output:\n\nDefault: `${request_clientip} [${time}] ${request_user_agent} \"${request_method} ${request_path_info} ${request_version}\" ${response_status} ${response_content_length}`\n\nPossible values: `time`,`time_short`,`execution_time`,`request_clientip`,`request_method`,`request_version`,`request_url`,`request_query`,`request_path_info`,`request_path_translated`,`request_cookie`,`request_accept`,`request_from`,`request_host`,`request_referer`,`request_user_agent`,`request_connection`,`request_derived_from`,`request_remote_addr`,`request_remote_host`,`request_script_name`,`request_server_port`,`request_remote_ip`,`request_internal_path_info`,`request_raw_path_info`,`request_cache_control`,`request_script_name`,`request_authorization`,`request_content_encoding`,`request_content_type`,`request_content_length`,`request_content_version`,`request_content`,`response_version`,`response_reason`,`response_server`,`response_realm`,`response_allow`,`response_location`,`response_log_message`,`response_title`,`response_content_encoding`,`response_content_type`,`response_content_length`,`response_content_version`,`response_content`,`response_status`\n\n## ⚡️ Quickstart Delphi\n```delphi\nuses\n  Horse,\n  Horse.Logger, // It's necessary to use the unit\n  Horse.Logger.Provider.LogFile, // It's necessary to use the unit\n  System.SysUtils;\n\n// var\n//   LLogFileConfig: THorseLoggerLogFileConfig;\n\nbegin\n  // LLogFileConfig := THorseLoggerLogFileConfig.New\n  //   .SetLogFormat('${request_clientip} [${time}] ${response_status}')\n  //   .SetDir('D:\\Servidores\\Log');\n\n  // You can also specify the log format and the path where it will be saved:\n  // THorseLoggerManager.RegisterProvider(THorseLoggerProviderLogFile.New(LLogFileConfig));\n\n  // Here you will define the provider that will be used.\n  THorseLoggerManager.RegisterProvider(THorseLoggerProviderLogFile.New());\n\n  // It's necessary to add the middleware in the Horse:\n  THorse.Use(THorseLoggerManager.HorseCallback);\n\n  THorse.Get('/ping',\n    procedure(Req: THorseRequest; Res: THorseResponse; Next: TProc)\n    begin\n      Res.Send('pong');\n    end);\n\n  THorse.Listen(9000);\nend;\n```\n\n## ⚡️ Quickstart Lazarus\n```delphi\n{$MODE DELPHI}{$H+}\n\nuses\n  {$IFDEF UNIX}{$IFDEF UseCThreads}\n  cthreads,\n  {$ENDIF}{$ENDIF}\n  Horse,\n  Horse.Logger, // It's necessary to use the unit\n  Horse.Logger.Provider.LogFile, // It's necessary to use the unit\n  SysUtils;\n\n// var\n//   LLogFileConfig: THorseLoggerLogFileConfig;\n\nprocedure GetPing(Req: THorseRequest; Res: THorseResponse; Next: TNextProc);\nbegin\n  Res.Send('Pong');\nend;\n\nbegin\n  // LLogFileConfig := THorseLoggerLogFileConfig.New\n  //   .SetLogFormat('${request_clientip} [${time}] ${response_status}')\n  //   .SetDir('D:\\Servidores\\Log');\n\n  // You can also specify the log format and the path where it will be saved:\n  // THorseLoggerManager.RegisterProvider(THorseLoggerProviderLogFile.New(LLogFileConfig));\n\n  // Here you will define the provider that will be used.\n  THorseLoggerManager.RegisterProvider(THorseLoggerProviderLogFile.New());\n\n  // It's necessary to add the middleware in the Horse:\n  THorse.Use(THorseLoggerManager.HorseCallback);\n\n  THorse.Get('/ping');\n\n  THorse.Listen(9000, OnListen);\nend.\n```\n\n## 📝 Output samples\nUsing default log formatting, the output will look something like this:\n```\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:34:53.949] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:34:55.842] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:34:56.887] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:35:24.458] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:35:31.638] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:35:32.685] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n0:0:0:0:0:0:0:1 [06/outubro/2021 10:35:33.590] PostmanRuntime/7.28.4 \"GET /ping HTTP/1.1\" 200 4\n```\n\n## ⚠️ License\n`horse-logger-provider-logfile` is free and open-source middleware licensed under the [MIT License](https://github.com/HashLoad/horse-logger-provider-logfile/blob/master/LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashload%2Fhorse-logger-provider-logfile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhashload%2Fhorse-logger-provider-logfile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhashload%2Fhorse-logger-provider-logfile/lists"}