Coder Social home page Coder Social logo

monolog-datadog's People

Contributors

guspio avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar

monolog-datadog's Issues

Set attributes after instance class

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

Plans to work with 2.3.5?

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.