Comments (7)
The monolog API is addRecord(integer|string $level, string $message, array $context)
. If you want include an array (or an object) in the log record, put it inside the context. You will then see it in Firephp
from monolog.
Ouch! Thank you and sorry, it was there and I didn't saw it
Finally I managed to create a "dirty" workaround overwriting handle in FirePHPHandler.
It's not so beautiful, but I just use it on developing, so, no performance issues.
/**
* {@inheritdoc}
*/
public function handle(array $record)
{
if ($record['level'] < $this->level) {
return false;
}
if(isset($record['context']['table'])){
require_once('Path/to/FirePHP.php');
fb($record['context']['table'], $record['message'], 'TABLE');
}
else {
return parent::handle($record);
}
}
using it this way
$log->debug("Benchmark", array('table'=>array(....)));
from monolog.
@Surt if you think this could be of some value in the core handler I'm not particularly against it, but I don't really use firephp so I am not sure. It seems to me like it's hard to say when something should be a table and when not. I mean it's context dependent, which is hard to solve in an abstraction.
from monolog.
Umm I'm not sure, I think that is not a good addition since it breaks a little the uniformity (don't know about other handlers).
Anyway, the issue could stay here for everyone looking for a workaround.
Anyone can drop a comment if they find the post useful.
by the way ;) Seldaek I can't stop using your Dwoo library. No one makes me feel like it :)
from monolog.
@Surt eh well, glad to hear but I would really recommend using twig just because dwoo is not going to receive much maintenance ever I'm afraid. And by now twig can do pretty much everything dwoo could besides the automatic php function mapping, but that is in a way for the best in terms of enforcing best practices.
from monolog.
@Seldaek Twig also has a way to map php functions to Twig functions automatically (but not documented and not recommended)
from monolog.
:) I know about Twig, I'm triying to use it but i don't like the syntax and need to rewrite my "plugins" again :(
About the post topic, my last contribution break the headers and nothing except tables appear on the logs, due to the Firephp core code.... so I manage to read the FirePHP Wildfire Wiki and ended with this on the "format" method of WildfireFormatter.php
if(isset($record['context']['table'])){
$type = 'TABLE';
$label = $record['message'];
$message = $record['context']['table'];
}
else {
$type = $this->logLevels[$record['level']];
$label = $record['channel'];
}
// Create JSON object describing the appearance of the message in the console
$json = $this->toJson(array(
array(
'Type' => $type,
'File' => $file,
'Line' => $line,
'Label' => $label,
),
$message
), $handleError);
as always, using it this way, so I can render tables at any level
$log->debug("Benchmark", array('table'=>array(....)));
The table array must be non-associative.
This code is better since it lives in the formatter and does not use the FirePHP library in any way (there was no need to use it anyway thanks to your great work)
from monolog.
Related Issues (20)
- The file does not close after writing HOT 5
- How do I use includeStacktraces? HOT 1
- Support more flexible normalizer HOT 2
- cannot access private method HOT 7
- Add support for Elasticsearch with Bulk API and data stream HOT 1
- Could a new release be considered to remove the 0.7MB logo from the package ? HOT 1
- Uncaught Error: Class "Monolog\Logger" not found HOT 7
- User definable duplication for DeduplicationHandler
- Encounter problem in format function HOT 3
- DatetimeImmutable HOT 1
- [Discussion] Reset FingersCrossedHandler on stateful runtimes HOT 8
- Extending Processors - private properties HOT 1
- Incorrect logs are written in Monolog files intermittently HOT 1
- Truncated JsonFormatter logs at 8191 characters HOT 5
- Log Message is truncated HOT 1
- Log level not compliant with rfc5424 HOT 2
- DeduplicationHandler in a read only container HOT 4
- IntrospectionProcessorTests: $expect and $actual are the same object by reference.
- Php 8.3 compatibility issue HOT 5
- Adding postParams in ERROR notice for HTTP 405 code HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monolog.