Skip to content

Commit

Permalink
[phalcon#13438] - Fixed tabs
Browse files Browse the repository at this point in the history
  • Loading branch information
niden authored and CameronHall committed Dec 8, 2018
1 parent bafd751 commit b43c637
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 70 deletions.
2 changes: 1 addition & 1 deletion phalcon/logger/adapter/noop.zep
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ class Noop extends AbstractAdapter
*/
public function process(<Item> item) -> void
{
// noop
// noop
}
}
12 changes: 6 additions & 6 deletions phalcon/logger/adapter/stream.zep
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,15 @@ class Stream extends AbstractAdapter
if !is_resource(this->handler) {
let this->handler = fopen(this->name, this->mode);

if !is_resource(this->handler) {
let $this->handler = null;
throw new \UnexpectedValueException(
sprintf("The file '%s' cannot be opened with mode '%s'", this->name, this->mode)
if !is_resource(this->handler) {
let $this->handler = null;
throw new \UnexpectedValueException(
sprintf("The file '%s' cannot be opened with mode '%s'", this->name, this->mode)
);
}
}
}

let formatter = this->getFormatter(),
let formatter = this->getFormatter(),
formattedMessage = formatter->format(item);

fwrite(this->handler, formattedMessage);
Expand Down
54 changes: 27 additions & 27 deletions phalcon/logger/adapter/syslog.zep
Original file line number Diff line number Diff line change
Expand Up @@ -48,24 +48,24 @@ class Syslog extends AbstractAdapter
*/
protected defaultFormatter = "Syslog";

/**
* @var int
*/
/**
* @var int
*/
protected facility = 0;

/**
* @var string
*/
/**
* @var string
*/
protected name = "";

/**
* @var bool
*/
/**
* @var bool
*/
protected opened = false;

/**
* @var int
*/
/**
* @var int
*/
protected option = 0;

/**
Expand All @@ -75,17 +75,17 @@ class Syslog extends AbstractAdapter
{
var option, facility;

if fetch option, options["option"] {
let option = LOG_ODELAY;
}
if fetch option, options["option"] {
let option = LOG_ODELAY;
}

if !fetch facility, options["facility"] {
let facility = LOG_USER;
}
if !fetch facility, options["facility"] {
let facility = LOG_USER;
}

let this->name = name,
this->facility = facility,
this->option = option;
let this->name = name,
this->facility = facility,
this->option = option;
}

/**
Expand Down Expand Up @@ -121,14 +121,14 @@ class Syslog extends AbstractAdapter
let result = openlog(name, option, facility);

if (!result) {
throw new \LogicException(
sprintf(
"Cannot open syslog for name [%s] and facility [%s]",
name,
facility
throw new \LogicException(
sprintf(
"Cannot open syslog for name [%s] and facility [%s]",
name,
facility
)
);
}
}

let opened = true,
this->opened = opened,
Expand Down
65 changes: 32 additions & 33 deletions phalcon/logger/factory.zep
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Factory extends BaseFactory

protected static function loadClass(string objectName, var config)
{
var adapter, adapterName, adapters, className, element, key, logger, loggerName, name, type;
var adapter, adapterName, adapters, className, element, key, logger, loggerName, name, type;

if typeof config == "object" && config instanceof Config {
let config = config->toArray();
Expand All @@ -53,43 +53,42 @@ class Factory extends BaseFactory
throw new Exception("Config must be array or Phalcon\\Config object");
}

if !fetch loggerName, config["name"] {
throw new Exception("You must provide the 'name' option in factory config parameter.");
}

if !fetch adapters, config["adapters"] {
throw new Exception("You must provide the 'adapters' option in factory config parameter.");
}

/**
* Loop through the adapters and ensure that they are ok.
*/
for adapter in adapters {
if !fetch name, adapter["name"] {
throw new Exception("The adapters section of your configuration is missing the 'name' option");
}
if !fetch loggerName, config["name"] {
throw new Exception("You must provide the 'name' option in factory config parameter.");
}

if !fetch type, adapter["adapter"] {
throw new Exception("The adapters section of your configuration is missing the 'adapter' option");
}
}
if !fetch adapters, config["adapters"] {
throw new Exception("You must provide the 'adapters' option in factory config parameter.");
}

/**
* If we got to here everything is OK. Lets set the objects
*/
let logger = new Logger(loggerName);
/**
* Loop through the adapters and ensure that they are ok.
*/
for adapter in adapters {
if !fetch name, adapter["name"] {
throw new Exception("The adapters section of your configuration is missing the 'name' option");
}

if !fetch type, adapter["adapter"] {
throw new Exception("The adapters section of your configuration is missing the 'adapter' option");
}
}

for key, element in adapters {
let name = element["name"],
type = element["adapter"],
adapterName = "A" . key,
className = objectName . "\\" . camelize(type),
adapter = new {className}(name);
/**
* If we got to here everything is OK. Lets set the objects
*/
let logger = new Logger(loggerName);

logger->addAdapter(adapterName, adapter);
for key, element in adapters {
let name = element["name"],
type = element["adapter"],
adapterName = "A" . key,
className = objectName . "\\" . camelize(type),
adapter = new {className}(name);

}
logger->addAdapter(adapterName, adapter);
}

return logger;
return logger;
}
}
6 changes: 3 additions & 3 deletions phalcon/logger/formatter/syslog.zep
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Syslog extends AbstractFormatter
*/
public function format(<Item> item) -> array
{
var message = item->getMessage(),
type = item->getType(),
context = item->getContext();
var message = item->getMessage(),
type = item->getType(),
context = item->getContext();

if typeof context === "array" {
let message = this->interpolate(message, context);
Expand Down

0 comments on commit b43c637

Please sign in to comment.