{"id":15286610,"url":"https://github.com/nickfan/channellog","last_synced_at":"2025-04-13T03:32:40.925Z","repository":{"id":57026674,"uuid":"87634102","full_name":"nickfan/ChannelLog","owner":"nickfan","description":"Support Laravel Log data to separate channel log files with config.","archived":false,"fork":false,"pushed_at":"2018-09-05T09:07:50.000Z","size":32,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-04-11T01:17:47.894Z","etag":null,"topics":["composer","laravel","monolog","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/nickfan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-08T12:59:52.000Z","updated_at":"2025-02-23T02:51:09.000Z","dependencies_parsed_at":"2022-08-23T16:20:37.023Z","dependency_job_id":null,"html_url":"https://github.com/nickfan/ChannelLog","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickfan%2FChannelLog","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickfan%2FChannelLog/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickfan%2FChannelLog/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nickfan%2FChannelLog/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nickfan","download_url":"https://codeload.github.com/nickfan/ChannelLog/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248659747,"owners_count":21141169,"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":["composer","laravel","monolog","php"],"created_at":"2024-09-30T15:17:41.659Z","updated_at":"2025-04-13T03:32:40.896Z","avatar_url":"https://github.com/nickfan.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ChannelLog\n\n[README in Chinese | 中文说明](README.zh-CN.md)\n\n## Intro\nSupport Laravel Log data to separate channel log files with config.\n\n\nthis project base on\n[ShQ's answer for laravel 5.2 custom log file for different tasks](http://stackoverflow.com/questions/37809989/laravel-5-2-custom-log-file-for-different-tasks)\n\n\n## Install\n\n* install composer package\n\n```\ncomposer require \"nickfan/channel-log:dev-master\"\n```\n\n* Edit config/app.php file\n\n **providers group add:**\n ```\nNickfan\\ChannelLog\\ChannelLogServiceProvider::class,\n ```\n\n **aliases group add:**\n```\n'ChannelLog' =\u003e Nickfan\\ChannelLog\\Facades\\ChannelLog::class,\n```\n\n* publish config file:\n\n```\nphp artisan vendor:publish --provider=\"Nickfan\\ChannelLog\\ChannelLogServiceProvider\"\n```\n\n## Setup\n\n```\nreturn [\n    'default' =\u003e [\n        'path' =\u003e 'logs/default.log',\n        'level' =\u003e \\Monolog\\Logger::DEBUG\n    ],\n//    'event' =\u003e [\n//        'path' =\u003e 'logs/event.log',\n//        'level' =\u003e \\Monolog\\Logger::INFO\n//    ],\n    'custom'=\u003e[  // Channel Label Name\n        'name'=\u003e'custom',           // (optional) Channel Label Name\n        'log'=\u003e'daily',             // log mode support: console (only in stdout); single (single file); daily (daily files); syslog (syslog); errorlog (php errorlog);\n        'console'=\u003etrue,            // output to stdout(console) at the sametime.\n        'path'=\u003e'logs/custom.log', // Log file path,relative path will convert to relative with storage_path(yourpath)\n        'level' =\u003e \\Monolog\\Logger::DEBUG, // Log Level\n        'log_syslog_name'=\u003e'channel_log',   // syslog mode log entry name\n        'log_max_files'=\u003e5,                 // max files keep in daily log mode\n        'formatter'=\u003e\\Nickfan\\ChannelLog\\ChannelLogJsonFormatter::class,           // (optional) Record Formatter Class Name\n    ],\n];\n\n\n```\n\n\n## Custom Configurator\n\nin a channel settings your could set your custom configurator by set\na key name: ```configurator```\n\nthe Configurator Class Must implements  ```Nickfan\\ChannelLog\\ChannelLogConfigurator ``` interface\n\nyou could write your own configurator reference\n```Nickfan\\ChannelLog\\ChannelLogDefaultConfigurator``` the default configurator class\n\nconfig example:\n\n```\nreturn [\n    'myconsole' =\u003e [  // Channel Label Name\n        'path' =\u003e 'logs/default.log', // Log file path,relative path will convert to relative with storage_path(yourpath)\n        'level' =\u003e \\Monolog\\Logger::DEBUG // Log Level\n        // set the configurator class name\n        'configurator' =\u003e \\App\\Support\\ChannelLogMyConsoleConfigurator::class\n    ],\n\n];\n```\n\n\n## Laravel Usage\n\n```\n\n// Log to 'default' channel\nChannelLog::channel('default')-\u003einfo('my test message {mykey1}',['mykey1'=\u003e'myval1','aaa'=\u003e'abc']);\n\n// Log to 'event' channel\nChannelLog::channel('event')-\u003eerror('my event message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n// Log to 'mycustom' channel in daily log mode ,with filepath '/tmp/mycustom-2017-10-24.log'\nChannelLog::daily('/tmp/mycustom.log')-\u003edebug('my custom message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n// Log to 'newdirect' channel in single log mode ,with filepath '/tmp/newdirect.log' , also log to console(stdout)\nChannelLog::direct([\n            'name'=\u003e'newdirect',// Channel Label Name\n            'console'=\u003etrue,    // output to console(stdout)\n            'path'=\u003e'/tmp/newdirect.log', // log filepath\n            ])-\u003edebug('new direct message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n\n```\n\n## Standalone Usage\n\n```\nuse Nickfan\\ChannelLog\\ChannelLogWriterStandAlone;\n\n$projectRoot = dirname(__DIR__);\n$channelLogWriter = new ChannelLogWriterStandAlone(\n  [\n      'default'=\u003e[\n          'log' =\u003e 'single',\n          'console'=\u003e false,\n          'path'=\u003e$projectRoot.'/logs/default.log',\n          'level'=\u003e\\Monolog\\Logger::INFO,\n      ],\n      'event' =\u003e [\n          'log' =\u003e 'daily',\n          'console'=\u003e true,\n          'path' =\u003e $projectRoot.'/logs/event.log',\n          'level' =\u003e \\Monolog\\Logger::DEBUG,\n      ],\n  ]\n);\n\n$channelLogWriter-\u003echannel('default')-\u003einfo('my test message {mykey1}',['mykey1'=\u003e'myval1','aaa'=\u003e'abc']);\n\n\n$result2 = $channelLogWriter-\u003echannel('event')-\u003eerror('my event message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n\n$result3 = $channelLogWriter-\u003edaily($projectRoot.'/logs/mycustom.log')-\u003edebug('my custom message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n\n$result4 = $channelLogWriter-\u003edirect($projectRoot.'/logs/mydirect.log')-\u003edebug('my direct message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n\n$result5 = $channelLogWriter-\u003edirect([\n            'name'=\u003e'newdirect',\n            'console'=\u003etrue,\n            'path'=\u003e$projectRoot.'/logs/newdirect.log',\n            ])-\u003edebug('new direct message {mykey2}',['mykey2'=\u003e'myval2','qqq'=\u003e'qwe']);\n\n```\n\n\n**more detail usage reference monolog offical site https://github.com/Seldaek/monolog**\n\n\n## Support on Beerpay\nHey dude! Help me out for a couple of :beers:!\n\n[![Beerpay](https://beerpay.io/nickfan/ChannelLog/badge.svg?style=beer-square)](https://beerpay.io/nickfan/ChannelLog)  [![Beerpay](https://beerpay.io/nickfan/ChannelLog/make-wish.svg?style=flat-square)](https://beerpay.io/nickfan/ChannelLog?focus=wish)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickfan%2Fchannellog","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnickfan%2Fchannellog","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnickfan%2Fchannellog/lists"}