Skip to content

Add util.log.LogConfiguration #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 24, 2018
Merged

Add util.log.LogConfiguration #12

merged 5 commits into from
Aug 24, 2018

Conversation

thekid
Copy link
Member

@thekid thekid commented Aug 24, 2018

See #11 (comment)

Configuration

[default]
uses=console|syslog|files

[console]
class=util.log.ConsoleAppender
level=ALL

[files]
class=util.log.FileAppender
args="/var/log/server.log"
level=ALL

[syslog]
class=util.log.SyslogUdpAppender
args=127.0.0.1|514|server
level=WARN|ERROR

API

$c= new LogConfiguration(new Properties('log.ini'));
$cat= $c->category('default');   // Returns console, syslog and files
$cat= $c->category('syslog');    // An appender as configured by "syslog"

$all= $c->categories();  // ["default" => new LogCategory()->withAppenders(...), "syslog" => ...

$name= 'does-not-exist';
$exists= $c->provides($name);    // FALSE
$cat= $c->category($name);       // ***lang.IllegalArgumentException***

Migration

- $l= Logger::getInstance();
- $l->configure(new Properties('log.ini'));
- $cat= $l->getCategory('default');
+ $c= new LogConfiguration(new Properties('log.ini'));
+ $cat= $c->category('default'); 

@thekid thekid merged commit bd50eee into master Aug 24, 2018
@thekid thekid deleted the feature/logconfig branch August 24, 2018 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant