Skip to content

Commit

Permalink
Add Cascade::hasLogger() (theorchard#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
DBX12 authored Jun 3, 2021
1 parent 034f018 commit 38e1b56
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Cascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ public static function logger($name)
return self::getLogger($name);
}

/**
* Checks if a logger with given name already exists.
*
* @param string $name Name of the requested Logger instance
*
* @return bool true - Logger already exists; false - Logger does not exist
*/
public static function hasLogger($name)
{
return Registry::hasLogger($name);
}

/**
* Return the config options
*
Expand Down
8 changes: 8 additions & 0 deletions tests/CascadeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,12 @@ public function testLoadConfigFromStringWithYaml()
Cascade::loadConfigFromString($yamlConfig);
$this->assertInstanceOf('Cascade\Config', Cascade::getConfig());
}

public function testHasLogger()
{
// implicitly create logger "existing"
Cascade::logger('existing');
$this->assertFalse(Cascade::hasLogger('not_existing'));
$this->assertTrue(Cascade::hasLogger('existing'));
}
}

0 comments on commit 38e1b56

Please sign in to comment.