forked from lxbarth/PuSHSubscriber
-
Notifications
You must be signed in to change notification settings - Fork 3
/
PEnvFile.php
36 lines (34 loc) · 1.03 KB
/
PEnvFile.php
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
<?php
/**
* Implement to provide environmental functionality like user messages and
* logging.
*/
class PEnvFile implements PuSHSubscriberEnvironmentInterface {
public static $msg_file = './logs/messages.log';
public static $log_file = './logs/system.log';
/**
* A message to be displayed to the user on the current page load.
*
* @param $msg
* A string that is the message to be displayed.
* @param $level
* A string that is either 'status', 'warning' or 'error'.
*/
public function msg($msg, $level = 'status') {
$data = "$level :: $msg\n";
file_put_contents(self::$msg_file, $data, FILE_APPEND|LOCK_EX);
}
/**
* A log message to be logged to the database or the file system.
*
* @param $msg
* A string that is the message to be displayed.
* @param $level
* A string that is either 'status', 'warning' or 'error'.
*/
public function log($msg, $level = 'status') {
$data = "$level :: $msg\n";
file_put_contents(self::$log_file, $data, FILE_APPEND|LOCK_EX);
}
}
?>