File: levels.phpt

package info (click to toggle)
php-log 1.13.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 496 kB
  • sloc: php: 1,917; xml: 593; makefile: 11; sql: 8
file content (74 lines) | stat: -rwxr-xr-x 1,339 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
--TEST--
Log: Levels
--INI--
date.timezone=UTC
--FILE--
<?php

require_once 'Log.php';

function verify($exp, $msg)
{
    echo $msg . ': ';
    echo ($exp) ? 'pass' : 'fail';
    echo "\n";
}

function testLevels($mask)
{
    echo "Mask: " . ($mask & 0xffff) . "\n";

    for ($priority = PEAR_LOG_EMERG; $priority <= PEAR_LOG_DEBUG; $priority++) {
        $masked = (Log::MASK($priority) & $mask);
        echo "Priority $priority: ";
        echo($masked) ? "masked\n" : "unmasked\n";
    }

    echo "\n";
}

testLevels(PEAR_LOG_NONE);
testLevels(PEAR_LOG_ALL);
testLevels(Log::MIN(PEAR_LOG_WARNING));
testLevels(Log::MAX(PEAR_LOG_WARNING));

--EXPECT--
Mask: 0
Priority 0: unmasked
Priority 1: unmasked
Priority 2: unmasked
Priority 3: unmasked
Priority 4: unmasked
Priority 5: unmasked
Priority 6: unmasked
Priority 7: unmasked

Mask: 65535
Priority 0: masked
Priority 1: masked
Priority 2: masked
Priority 3: masked
Priority 4: masked
Priority 5: masked
Priority 6: masked
Priority 7: masked

Mask: 65520
Priority 0: unmasked
Priority 1: unmasked
Priority 2: unmasked
Priority 3: unmasked
Priority 4: masked
Priority 5: masked
Priority 6: masked
Priority 7: masked

Mask: 31
Priority 0: masked
Priority 1: masked
Priority 2: masked
Priority 3: masked
Priority 4: masked
Priority 5: unmasked
Priority 6: unmasked
Priority 7: unmasked