guspio / monolog-datadog Goto Github PK
View Code? Open in Web Editor NEWMonolog Handler for Datadog Logs
License: MIT License
Monolog Handler for Datadog Logs
License: MIT License
Please add php 8 support
Is it possible to set $attributes after instantiating the class
// LOGGER
$logger = new Logger('api');
$attributes = [
'hostname' => $this->settings['server_name'],
'source' => 'php',
'service' => 'skyhub'
];
$dataDogHandler = new DatadogHandler("xxxxxxxx", $attributes, LogLevel::DEBUG);
$dataDogHandler->setFormatter(new JsonFormatter());
$dataDogHandler->pushProcessor(function ($record) {
list($method, $uri, $request, $code, $response, $phrase, $error) = explode("#|#", $record["message"]);
$record['message'] = $uri;
$record['context']['method'] = $method;
$record['context']['uri'] = $uri;
$record['context']['request'] = $request;
$record['context']['code'] = $code;
$record['context']['response'] = $response;
$record['context']['phrase'] = $phrase;
$record['context']['error'] = $error;
$record['context'] = array_filter($record['context']);
return $record;
});
$logger->pushHandler($dataDogHandler);
$stack = HandlerStack::create();
$mapResponse = Middleware::mapResponse(function (ResponseInterface $response) {
$response->getBody()->rewind();
return $response;
});
$stack->push($mapResponse);
$stack->push(Middleware::log($logger, new MessageFormatter('{method}#|#{uri}#|#{req_body}#|#{code}#|#{res_body}#|#{phrase}#|#{error}'), LogLevel::DEBUG));
// SET ATTRIBUTES
Currently a downgrade of Monolog is required to satisfy the dependencies of monolog-datadog.
For me, this breaks some other features of Monolog that I require.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.