hack-logging / hack-logging
Hack Logging Package
Fund package maintenance!
ytake
Installs: 8 610
Dependents: 1
Suggesters: 0
Security: 0
Stars: 4
Watchers: 3
Forks: 1
Open Issues: 0
Language:Hack
Requires
- hhvm: ^4.95
- hhvm/hsl: ^4.95
- hhvm/hsl-experimental: ^4.95
Requires (Dev)
- facebook/fbexpect: ^2.7
- hhvm/hacktest: ^2.2
- hhvm/hhast: ^4.95
- hhvm/hhvm-autoload: ^3.2
README
Requirements
HHVM 4.95 and above.
Usage
$ composer require hack-logging/hack-logging
StdHandler
use namespace HackLogging; use namespace HH\Lib\IO; async function fvAsync(): Awaitable<void> { list($read, $write) = IO\pipe(); $log = new HackLogging\Logger('hack-logging', vec[ new HackLogging\Handler\StdHandler($write), ]); await $log->writeAsync( HackLogging\LogLevel::DEBUG, 'hacklogging-test', ); }
FilesystemHandler
use namespace HackLogging; use namespace HH\Lib\File; use function bin2hey(); use function random_bytes; use function sys_get_temp_dir; async function fvAsync(): Awaitable<void> { $filename = sys_get_temp_dir() . '/' . bin2hex(random_bytes(16)); $file = File\open_write_only($filename); $log = new HackLogging\Logger('hack-logging', vec[ new HackLogging\Handler\FilesystemHandler($file), ]); await $log->writeAsync( HackLogging\LogLevel::DEBUG, 'hacklogging-test', dict[ 'context' => vec['nice'], ], ); }