{"id":31528426,"url":"https://github.com/yidayoung/lager_html","last_synced_at":"2025-10-03T23:40:38.437Z","repository":{"id":57514841,"uuid":"213845987","full_name":"yidayoung/lager_html","owner":"yidayoung","description":"基于lager生成html文件，易于查看","archived":false,"fork":false,"pushed_at":"2021-06-29T08:55:38.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-09-21T02:27:36.766Z","etag":null,"topics":["erlang","html","lager","lager-html"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","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/yidayoung.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":"2019-10-09T07:07:20.000Z","updated_at":"2021-06-29T08:55:41.000Z","dependencies_parsed_at":"2022-08-30T01:40:28.223Z","dependency_job_id":null,"html_url":"https://github.com/yidayoung/lager_html","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yidayoung/lager_html","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidayoung%2Flager_html","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidayoung%2Flager_html/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidayoung%2Flager_html/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidayoung%2Flager_html/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yidayoung","download_url":"https://codeload.github.com/yidayoung/lager_html/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yidayoung%2Flager_html/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278245356,"owners_count":25955013,"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-10-03T02:00:06.070Z","response_time":53,"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":["erlang","html","lager","lager-html"],"created_at":"2025-10-03T23:40:36.731Z","updated_at":"2025-10-03T23:40:38.433Z","avatar_url":"https://github.com/yidayoung.png","language":"Erlang","funding_links":[],"categories":[],"sub_categories":[],"readme":"# lager_html\n基于lager生成html文件，易于查看  \n![image](images/log.jpeg)  \n\n简单的来说就是加了自定义的formatter和rotator,其他内容保持和lager一致\n\n\n你必须把下面的内容覆盖到lager的环境变量中\n```erlang\n[\n    {log_root, \"./log\"},\n    {handlers, [\n        {lager_file_backend,\n            [\n                %% 日志文件前缀，全名是 File++Date.html\n                {file, \"error_log\"},\n                %%debug=128, info=64, notice=32, warning=16, error=8, critical=4, alert=2, emergency=1, none=0\n                {level, info},\n                {formatter, lager_log_html_formatter},\n                %% 字符串格式，可选值，使用lager_log_html_formatter后默认模板会改成以下内容\n%%                    {formatter_config, [\"\u003cdiv\u003e\u003cfont size=\\\"2\\\" color=\", html_color, \"\u003e\\n== \", date, \" \",\n%%                        time, \" ===\", sev, \"(\", pid, module, \":\", function, \":\", line, \") ： \", message, \"\\n\u003c/font\u003e\u003c/div\u003e\"]},\n                %% 每天生成新日志文件，最多保留30个\n                {date, \"$D0\"},\n                {count, 30},\n                {rotator, lager_log_html_rotator}\n            ]}\n    ]},\n    %% error_logger重定向\n    {error_logger_redirect, true},\n\n    %% crash_log\n    {crash_log, \"crash.log\"}, %% crash.log文件名\n    {crash_log_count, 5},    %% 最多保存5个crash.log文件\n    {crash_log_date, \"$Ml\"} %% 每月最后一天生成一个新的crash.log\n\n    %% html染色,替换lager_log_html_formatter提供的模板中的html_color字段，可选值，默认值如下\n    %% {html_colors, [\n    %%     {error, \"\\\"#FF0000\\\"\"},\n    %%     {warning, \"\\\"#FFCC33\\\"\"},\n    %%     {debug, \"\\\"#00FFD2\\\"\"},\n    %%     {info, \"\\\"#00FF00\\\"\"},\n    %%     {critical, \"\\\"#6C2A6D\\\"\"}]}\n\n]\n```\n\n可以选择在启动参数里加入 -config xx.config xx.config中的内容 {lager, KV}.  \n或者在rebar.config中加入get-deps的hook，在每次拉取下来的时候重新修改lager的 lager.app.src中的默认环境变量  \n不推荐在代码中调用application:set_env来实现，因为lager.app.src中会覆盖之前的内容，而且lager很多参数都是启动时生效，后续不能修改  \n\n\n## 测试\n在rebar.config 的erl_opts 中加入`{src_dirs, [\"src\", \"test\"]}`编译    \n在项目目录下执行`erl -pa ebin deps/lager/ebin deps/goldrush/ebin -config test/lager_html_test.config`  \n执行 `lager_html_test:test().`  \nlog目录下就会生成对应的日志文件\n\n\n## 使用\n也可以仿照lager_log_html_formatter和lager_log_html_rotator写两个类似的模块放到自己的工程项目中，\n项目本身并没有其他扩展","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyidayoung%2Flager_html","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyidayoung%2Flager_html","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyidayoung%2Flager_html/lists"}