Skip to content

Commit

Permalink
Release 1.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
atroxaper committed Feb 23, 2021
2 parents 5d8592e + eb3c0aa commit cf7bd0e
Show file tree
Hide file tree
Showing 17 changed files with 131 additions and 46 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/main.yml → .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
name: build
name: Ubuntu

on:
push:
branches:
- dev
- master
branches: [ master, dev ]
pull_request:
branches: [ master ]

workflow_dispatch:

jobs:
build:
name: prove
Expand Down
68 changes: 68 additions & 0 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Windows

on:
push:
branches: [ master, dev ]
pull_request:
branches: [ master ]

workflow_dispatch:

jobs:
build:
name: prove
runs-on: windows-latest
env:
RAKUBREW_HOME: engine/brew
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Set PATH
shell: bash
run: |
echo "$GITHUB_WORKSPACE/engine/brew/shims" >> $GITHUB_PATH
echo "$GITHUB_WORKSPACE/engine" >> $GITHUB_PATH
- name: Install Rakubrew
uses: suisei-cn/actions-download-file@v1
with:
url: "https://rakubrew.org/win/rakubrew.exe"
target: engine/

- name: Install Raku
run: |
rakubrew mode shim
rakubrew download
raku -v
- uses: suisei-cn/actions-download-file@v1
name: Download Zef
with:
url: https://github.com/ugexe/zef/tarball/master
target: engine/

- name: Unpack Zef
shell: bash
run: |
mkdir engine/zef
tar -xf engine/master -C engine/zef --strip 1
- name: Install Zef [no tests]
working-directory: engine/zef
run: |
raku -I. bin/zef install . --/test
rakubrew rehash
env:
RAKUBREW_HOME: ../brew

- name: Install Prove6 [no tests]
run: |
zef install App::Prove6 --/test
rakubrew rehash
- name: Install dependencies [no tests]
run: zef install . --deps-only --/test

- name: Tests
run: prove6
6 changes: 6 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
Version history:

1.6.4 2021-02-23 'Test on Windows'
- Fix tests for Windows
- Fix flappy test for callframes
- Moved from TravisCI to GitHub Actions
- Add CI for Windows as well as for Ubuntu

1.6.3 2020-12-29 'fix README'
- Improve language in README
- For now we can use 'positional' array for positional argument in custom section in config file
Expand Down
2 changes: 1 addition & 1 deletion META6.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "LogP6",
"description": "Full customisable logging library inspired by idea of separate logging and its configuration.",
"version": "1.6.3",
"version": "1.6.4",
"perl": "6.d",
"authors": [
"Mikhail Khorkov"
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Build Status](https://github.com/atroxaper/p6-LogP6/workflows/build/badge.svg)](https://github.com/atroxaper/p6-LogP6/actions)
[![Build Status](https://github.com/atroxaper/p6-LogP6/workflows/Ubuntu/badge.svg)](https://github.com/atroxaper/p6-LogP6/actions/workflows/ubuntu.yml)
[![Build Status](https://github.com/atroxaper/p6-LogP6/workflows/Windows/badge.svg)](https://github.com/atroxaper/p6-LogP6/actions/workflows/windows.yml)

# NAME

Expand Down
2 changes: 1 addition & 1 deletion lib/LogP6.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ sub clean-all-settings() {
unless Grammar.parse($default-pattern);
$default-auto-exceptions = True;
$default-handle = $*OUT;
$default-x-pattern = '%x{ Exception $name: $msg' ~ "\n" ~ '$trace}';
$default-x-pattern = '%x{ Exception $name: $msg' ~ $?NL ~ '$trace}';

$default-level = Level::error;
$default-first-level-check = True;
Expand Down
4 changes: 2 additions & 2 deletions lib/LogP6/ConfigFile.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class LogP6::ConfigFile {
CATCH {
default {
die "Cannot read and create config from file $file-path. Cause "
~ $_.^name ~ ': ' ~ $_.gist, "\n";
~ $_.^name ~ ': ' ~ $_.gist;
}
}
return LogP6::Config.new unless $file-path.e;
Expand Down Expand Up @@ -123,7 +123,7 @@ class LogP6::ConfigFile {
}

method !string-e(\json) {
return json.Str.trans(['\e', '\a', '\n'] => ["\e", "\a", "\n"]) with json;
return json.Str.trans(['\e', '\a', '\n'] => ["\e", "\a", $?NL]) with json;
return Str;
}

Expand Down
2 changes: 1 addition & 1 deletion lib/LogP6/Exceptions.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class X::LogP6::PatternIsNotValid is Exception {
}

multi sub logp6-error(Exception:D $x) is export {
$*ERR.print('LogP6 error: ', $x.^name, ': ', $x.message, "\n", $x.backtrace);
$*ERR.print('LogP6 error: ', $x.^name, ': ', $x.message, $?NL, $x.backtrace);
}

multi sub logp6-error(Str:D $x) is export {
Expand Down
7 changes: 5 additions & 2 deletions t/00-config-file-writers.t
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@ use LogP6::ConfigFile;
use lib './t/resource/Helpers';
use lib './t/resource/00-config-file';

# we use Unix style file paths in config file for the test
plan :skip-all<These tests do not work on Windows> if $*DISTRO.is-win;
plan 25;

CATCH { default {say .gist }}
my $folder = '/tmp/logp6'.IO;
mkdir $folder;
END {
*.unlink for $folder.dir;
$folder.rmdir;
if $folder {
*.unlink for $folder.dir;
$folder.rmdir;
}
}

my LogP6::ConfigFile $config .= new;
Expand Down
2 changes: 1 addition & 1 deletion t/00-config-file.t
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ subtest {
ok defined($default-io), 'default io ok';
is $default-io.writed.trim, 'logdebug test ex', 'defaults ok';
ok defined($cliche-io), 'cliche io ok';
is $cliche-io.writed.trim, "goltrace X::AdHoc\ngoldebug X::AdHoc",
is $cliche-io.writed.lines.List, ("goltrace X::AdHoc", "goldebug X::AdHoc"),
'cliche ok';

my $wrapper = get-cliche('c2').wrapper;
Expand Down
2 changes: 1 addition & 1 deletion t/00-context.t
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ is-deeply $context.mdc, %(), 'mdc-clean';

# date
my $default-date = $context.date;
my $setted-date = DateTime.now;
my $setted-date = DateTime.now + Duration.new(60);
ok $default-date.defined, 'default date';
$context.date-set($setted-date);
is $context.date, $setted-date, 'setted date';
Expand Down
12 changes: 7 additions & 5 deletions t/00-grammar.t
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,16 @@ sub parse-process($pattern) {
}

# simple
is parse-process('%trait %tid-%tname %ndc-%mdc{foo}:%msg:%level*%date*%x').trim,
"test trait $tid-$tname 12 34-mdc-value:test message:INFO*23:54:09:123*" ~
"Exception X::AdHoc: test exception\n" ~ $backtrace,
is parse-process('%trait %tid-%tname %ndc-%mdc{foo}:%msg:%level*%date*%x')
.lines.List,
("test trait $tid-$tname 12 34-mdc-value:test message:INFO*23:54:09:123*" ~
"Exception X::AdHoc: test exception", $backtrace),
'full pattern without preferences';

# %x
is parse-process('%x{$name}:%x{$msg};%x{$msg_$name_' ~ "\n" ~'$trace}').trim,
"X::AdHoc:test exception;test exception_X::AdHoc_\n" ~ $backtrace,
is parse-process('%x{$name}:%x{$msg};%x{$msg_$name_' ~ "\n" ~'$trace}')
.lines.List,
("X::AdHoc:test exception;test exception_X::AdHoc_", $backtrace),
'%x pattern';

# %date
Expand Down
2 changes: 1 addition & 1 deletion t/00-handle-async-single.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $async.say('boom');
$async.say('moob');
sleep(1);

is $delegate.clean, "boom\nmoob\n", 'delegate writes';
is $delegate.clean.lines.List, ("boom", "moob"), 'delegate writes';

$async.close;
ok $delegate.closed, 'delegate closed';
Expand Down
2 changes: 1 addition & 1 deletion t/00-handle-async.t
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ $async.say('boom');
$async.say('moob');
sleep(1);

is $delegate.clean, "boom\nmoob\n", 'delegate writes';
is $delegate.clean.lines.List, ("boom", "moob"), 'delegate writes';

$async.close;
ok $delegate.closed, 'delegate closed';
Expand Down
4 changes: 2 additions & 2 deletions t/00-logger-wrapper-sync-time.t
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ subtest {
$logger.info('log this yet');
sleep(1.2);
$logger.info('ignore this');
is $h.clean, "log this yet\n", 'mute logger is turned off';
is $h.clean.trim, "log this yet", 'mute logger is turned off';

cliche(:name($cliche.name), :matcher($cliche.matcher),
grooves => <writer filter>, :replace);
Expand All @@ -52,7 +52,7 @@ subtest {
$logger.info('log this yet');
sleep(1);
$logger.info('ignore this');
is $h.clean, "log this yet\n", 'general logger is changed level';
is $h.clean.trim, "log this yet", 'general logger is changed level';

filter(:name<filter>, :level($info), :replace);
sleep(1);
Expand Down
46 changes: 24 additions & 22 deletions t/00-logger.t
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ subtest {
$general.info('g info');
$general.debug('g debug');

is $h1.clean, "g error\n", 'first filter is ok in general log';
is $h2.clean, "g error\ng info\ng debug\n", 'first filter nok in general log';
is $h1.clean.trim, "g error", 'first filter is ok in general log';
is $h2.clean.lines.List, ("g error", "g info", "g debug"),
'first filter nok in general log';
}, 'simple reactive check';

subtest {
Expand Down Expand Up @@ -66,8 +67,9 @@ subtest {
$hard.debug('h debug');
$hard.trace('h trace but error');

is $h1.clean, "h error\nh warn\n", 'first filter is ok in hard log';
is $h2.clean, "h error\nh trace but error\n", 'first filter nok in hard log';
is $h1.clean.lines.List, ("h error", "h warn"), 'first filter is ok in hard log';
is $h2.clean.lines.List, ("h error", "h trace but error"),
'first filter nok in hard log';
}, 'difficult reactive check';

subtest {
Expand All @@ -94,9 +96,10 @@ subtest {
$reset.warn('r warn');
$reset.info('r info');

is $h1.clean, "TRACE Ur error\nTRACE Ur warn\n",
is $h1.clean.lines.List, ("TRACE Ur error", "TRACE Ur warn"),
'first filter is ok in reset log';
is $h2.clean, "ERROR r error test exception\nWARN r warn\nINFO r info\n",
is $h2.clean.lines.List,
("ERROR r error test exception", "WARN r warn", "INFO r info"),
'first filter nok in reset log';
}, 'reset context';

Expand Down Expand Up @@ -145,43 +148,43 @@ subtest {
my $ndc = get-logger('ndc');

$ndc.info('msg');
is $h1.clean, "msg \n", 'empty ndc and mdc';
is $h1.clean.trim, "msg", 'empty ndc and mdc';

$ndc.ndc-push('n-one');
$ndc.info('msg');
is $h1.clean, "msg n-one \n", 'ndc one element';
is $h1.clean.trim, "msg n-one", 'ndc one element';

$ndc.ndc-push('n-two');
$ndc.info('msg');
is $h1.clean, "msg n-one n-two \n", 'ndc two elemets';
is $h1.clean.trim, "msg n-one n-two", 'ndc two elemets';

$ndc.mdc-put('foo', 'bar');
$ndc.info('msg');
is $h1.clean, "msg n-one n-two bar\n", 'ndc two elements and mdc';
is $h1.clean.trim, "msg n-one n-two bar", 'ndc two elements and mdc';

$ndc.mdc-put('bar', 'foo');
$ndc.info('msg');
is $h1.clean, "msg n-one n-two bar\n", 'ndc two elements and mdc again';
is $h1.clean.trim, "msg n-one n-two bar", 'ndc two elements and mdc again';

$ndc.mdc-put('oof', 'rab');
$ndc.info('msg');
is $h1.clean, "msg n-one n-two barrab\n", 'ndc two elements and mdc two';
is $h1.clean.trim, "msg n-one n-two barrab", 'ndc two elements and mdc two';

$ndc.mdc-remove('foo');
$ndc.info('msg');
is $h1.clean, "msg n-one n-two rab\n", 'ndc two elements and mdc second';
is $h1.clean.trim, "msg n-one n-two rab", 'ndc two elements and mdc second';

$ndc.mdc-clean();
$ndc.info('msg');
is $h1.clean, "msg n-one n-two \n", 'ndc two elements and mdc clean';
is $h1.clean.trim, "msg n-one n-two", 'ndc two elements and mdc clean';

$ndc.ndc-pop();
$ndc.info('msg');
is $h1.clean, "msg n-one \n", 'ndc pop element';
is $h1.clean.trim, "msg n-one", 'ndc pop element';

$ndc.ndc-clean();
$ndc.info('msg');
is $h1.clean, "msg \n", 'ndc clean';
is $h1.clean.trim, "msg", 'ndc clean';
}, 'ndc and mdc';

subtest {
Expand All @@ -198,23 +201,22 @@ subtest {
use LogP6::Wrapper::SyncEach;

cliche(:name<frame1>, :matcher<frame1>, grooves => (
writer(:pattern('%msg %framename %framefile %frameline'), :handle($h1)),
writer(:pattern('%msg %framefile %frameline'), :handle($h1)),
level($info)
));
cliche(:name<frame2>, :matcher<frame2>, grooves => (
writer(:pattern('%msg %framename %framefile %frameline'), :handle($h1)),
writer(:pattern('%msg %framefile %frameline'), :handle($h1)),
level($info)
), :wrapper(LogP6::Wrapper::SyncEach::Wrapper.new));
my $frame1 = get-logger('frame1');
my $frame2 = get-logger('frame2');

$frame1.info('line 1');
my $l1 = $h1.clean;
$frame1.infof('line 2');
$frame2.infof('line 2');
my @l2 = $h1.clean.trim.split("\n");
$frame1.infof('line 2'); $frame2.infof('line 2');
my @l2 = $h1.clean.lines.List;
isnt $l1, @l2[0], 'frames are different';
is @l2[1].substr(0, *-1), @l2[0].substr(0, *-1), 'frames are the same';
is @l2[1], @l2[0], 'frames are the same';
}, 'different frame';

subtest {
Expand Down
2 changes: 1 addition & 1 deletion t/00-writer-async.t
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ $log.info('boom');

sleep(1);

is $handle.clean(), "boom\n", 'delegate writes';
is $handle.clean().trim, "boom", 'delegate writes';
$async.close;
ok $handle.closed, 'handle closed';

Expand Down

0 comments on commit cf7bd0e

Please sign in to comment.