Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ytake/hack-logging
Send logs to files For HHVM/Hack
https://github.com/ytake/hack-logging
hacklang hhvm logger logging
Last synced: 7 days ago
JSON representation
Send logs to files For HHVM/Hack
- Host: GitHub
- URL: https://github.com/ytake/hack-logging
- Owner: ytake
- License: mit
- Created: 2019-01-01T16:49:10.000Z (about 6 years ago)
- Default Branch: main
- Last Pushed: 2023-08-11T12:49:03.000Z (over 1 year ago)
- Last Synced: 2024-10-05T22:03:03.840Z (4 months ago)
- Topics: hacklang, hhvm, logger, logging
- Language: Hack
- Homepage:
- Size: 51.8 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# hack-logging
[![Build Status](https://travis-ci.org/ytake/hack-logging.svg?branch=master)](https://travis-ci.org/ytake/hack-logging)
## Requirements
HHVM 4.95 and above.
## Usage
```bash
$ composer require hack-logging/hack-logging
```### StdHandler
```hack
use namespace HackLogging;
use namespace HH\Lib\IO;async function fvAsync(): Awaitable {
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
```hack
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 {
$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'],
],
);
}
```