hack-logging/hack-logging

Hack Logging Package

Installs: 5 355

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 0

Language:Hack

0.7.1 2020-07-03 00:53 UTC

This package is auto-updated.

Last update: 2020-09-03 01:22:46 UTC


README

Build Status

Requirements

HHVM 4.41.0 and above.

Usage

$ composer require hack-logging/hack-logging

StdHandler

use type HackLogging\Logger;
use type HackLogging\LogLevel;
use type HackLogging\Handler\StdHandler;
use namespace HH\Lib\IO;

list($read, $write) = IO\pipe();
$log = new Logger('hack-logging', vec[
  new StdHandler($write)
]);
\HH\Asio\join(
  $log->writeAsync(LogLevel::DEBUG, 'hacklogging-test')
);

FilesystemHandler

use type HackLogging\Logger;
use type HackLogging\LogLevel;
use type HackLogging\Handler\FilesystemHandler;
use namespace HH\Lib\File;

$filename = sys_get_temp_dir().'/'.bin2hex(random_bytes(16));
$file = File\open_write_only($filename);
$log = new Logger('hack-logging', vec[
  new FilesystemHandler($file)
]);
\HH\Asio\join(
  $log->writeAsync(LogLevel::DEBUG, 'hacklogging-test', dict['context' => vec['nice']])
);