Coder Social home page Coder Social logo

browser-bunyan's People

Contributors

andreineculau avatar antobinary avatar bcantrill avatar cb1kenobi avatar chad3814 avatar connor4312 avatar danieljuhl avatar dependabot[bot] avatar dokie avatar gausby avatar isaacs avatar jnordberg avatar joshwilsdon avatar kcivey avatar loicpirez avatar matomesc avatar maximkhlobystov avatar mhart avatar mmalecki avatar motammi avatar notmatt avatar peitschie avatar pfmooney avatar philmander avatar poky85 avatar ricardograca avatar rmg avatar sethpollack avatar simonexmachina avatar trentm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

browser-bunyan's Issues

Support sourcemap locations like `console.log`?

Currently, bunyan's req.src shows the compiled location (an asset bundle), as opposed to the location in the sourcemap.

browser-bunyan

// ConsoleFormattedStream
... Class.updateCount (http://localhost:4200/assets/project-assets.js:1382:12) bunyan.js:259
// stdout
...
src: "Class.updateCount (http://localhost:4200/assets/project-assets.js:1382:12)"

NB: Asset compilation was performed via Broccoli (ember-cli build pipeline)

console.log

log message   local-file.js.js:93

NB: Identical behavior between browerified node-bunyan and browser-bunyan

is there an server implementation?

Thank you for this project. I read the docs and it support send the logs to a server endpoint. But I did not find any server implementation details, is there an existing implementation or we need to implement a simple server endpoint to receive the logs manually (it seems not very difficult though).

Thanks,
Shenghong

flushOnClose sends records as text/plain instead of application/json

I noticed that when flushOnClose is on, browser-bunyan's ServerStream seems to be sending out the records with content-type set as text/plain instead of application/json.

const blob = new Blob([JSON.stringify(recs)], { type : 'text/plain' });

Is this intentional?

I've been accepting application/json from browser-bunyan and I've been seeing 415 errors because of invalid content-type.

Thanks!

Log API Throttle / Initialization Issue

It appears that any messages that are logged before the logApiThrottle (in milliseconds) time has passed are not passed to the network call. When we wait for this amount of time before calling logger.info it will pass this first log to the network request.

i.e

const throttle = 500
const logger = getLogger({
  name: 'Client',
  logApiUri: "/test",
  streams: { isServerStreamEnabled: true },
  throttleInterval: throttle,
});

logger.info("testing") // not sent over network

setTimeout(() => logger.info("testing"), throttle) // sent over network

Messages that are sent directly after initialization are not passed to the network call

no contributors guide

Hi @philmander,

Thanks for the package, great stuff! ๐ŸŽ‰

I am using the logger with console-formatted-stream I would like to have the formatted stream gracefully support objects passed as arguments. Today it prints out [object Object].

I think it is pretty simple, multiple arguments could be passed to console.log instead of using argument substitution.

Forked

I have forked the package.

I did this in my fork:

npm install -g lerna
cd browser-bunyan
npm install
lerna bootstrap
lerna publish
npm link

Tried to modify

I changed some source code and tried to see if I inspect the code. I seem unable to make a change that gets picked up by my package pointer in the node_modules file.

Confused

  • How can I make a simple change that I can check out? I do not think simple npm link is working for me.
  • How can I construct a debug build? All the code is minimized by the lerna build with microbundle? I looked at the flags for these tools and nothing stands out.
  • lerna publish only seems to build the git HEAD?
  • I made modifications in the package and then ran npm run build which runs microbundle directly.

If I had a simple guide to forking and debugging I could add the feature that I would like to see and maybe send you a PR.

Thanks!

Extra log fields are not logged to browser console

When I do something like:

log.warn({foo: "bar"}, 'hello')

with ConsoleFormattedStream, the object fields are not shown in the JavaScript console.

I feel like this used to work, but not any more. Maybe they changed something in Chrome.

image

image

To reproduce, set up a browser-bunyan logger with ConsoleFormattedStream and try logging an object parameter in the latest version of Chrome, see if it shows the object or not.

Is jest not running ServerStream?

export function myLogger(): void {
    const logger = createLogger({
        name: 'myLogger',
        level: INFO, 
        stream: new ServerStream({
            url: 'http://0.0.0.0:8080/sandbox',
            method: 'POST'
        }),
    });
    logger.info("testtest"); 
}

I have this basic implementation of ServerStream, and I'm trying to write a test to check that ServerStream is actually working.

However, when I run the jest test, I realize that my endpoint never gets hit when the test is running.

However, when I run this function normally, I am able to see that the endpoint is hit

Is this an expected behavior?

Add custom headers to ServerStream

hi, right now i am sending logs to a server using server-stream, but i need to add custom headers in the request, is there any way to do that ? here is an example of how i am doing it:

logInstance = createLogger({
name: 'my-landing',
streams: [{
level: INFO,
stream: new ServerStream({
url: ${config.baseURLbff}logs,
method: 'POST',
}),
}],
})

Removal of streams

Hi,

I have added seq (via bunyan-seq) to my bunyan-browser config to send message to a server. However, when the server is not available bunyan-browser throws an error.

I already registered an onError handler to the my stream, but that just shows, a message to the console that an error occured. I would like to remove the stream from my logger to avoid further error, especially failures in my app, due to a not reachable stream.

Is there any way to remove a stream from an existing logger?

[ConsoleFormattedStream]: Log objects to the same console line as the log output

When logging objects, the object is output on the line following the formatted text output.

This is pretty much fine when reading through the logs. But when using console filter/find features it is a total pain. Because the object is output on the next line and it is not available in the search results.

Workaround

It is pretty simple to modify ConsoleFormattedStream to output the object on the same line.

        if (rec.src) {
             logArgs.push(srcCss);
             logArgs.push(rec.src);
         }
+        if (rec.obj) {
+          logArgs.push(rec.obj);
+      }

         consoleMethod.apply(console, logArgs);
         if (rec.err && rec.err.stack) {
             consoleMethod.call(console, '%c%s,', levelCss, rec.err.stack);
         }
-        if (rec.obj) {
-            consoleMethod.call(console, rec.obj);
-        }

browser-bunyan.min.js missing bunyan.ServerStream

Hi,
For <script src="//unpkg.com/[email protected]/dist/browser-bunyan.min.js"></script>, I am able to instantiate bunyan.ConsoleRawStream and ConsoleRawStream.ConsoleFormattedStream but not bunyan.ServerStream. Can we have bunyan.ServerStream package into browser-bunyan.min.js?

Thanks

Add logic to send on `onbeforeunload`

It would be nice if the server-stream package would also send it's current batch (regardless of if it's full) when the browser is about to close the tab.
This would avoid lost log messages between the last batch sent and when the browser shuts down the tab.

Ability to give headers through function and/or promise

Assuming that I for example want to have auth headers (like Bearer token), these may need to be updated from time to time. If headers could be configured to be provided through a (async) function called on each request to send to the server, that would be a simple solution for the library user.

Angular example in documentation is incomplete

"var bunyan = require('./lib/bunyan');" as given in the documentation example is NodeJS code, you cannot use that in browser. Hence the provided example of

<...>
$delegate = bunyan.createLogger({
<...>

is extremely unclear - where does the "bunyan" instance come from? When I attempt to inject "bunyan" or "browser-bunyan" into my Angular module, I get "Module 'bunyan' (or "browser-bunyan") is not available!" errors.

Could you please clarify documentation regarding how it's supposed to be done?

ServerStream outputs an array of JSON

Is it possible for ServerStream to send the request body as a single JSON instead of an array of JSON?

export function testLogger(): void {
    const logger = createLogger({
        name: 'myLogger',
        streams: [
            {
                level: INFO, 
                stream: new ServerStream({
                    url: 'http://0.0.0.0:8080/sandbox',
                    method: 'POST'
                }),
            }
        ],
    });
    logger.info({"test" : "test123"}); 
}

Output:

[  
   {  
      "name":"myLogger",
      "level":30,
      "test":"test123",
      "levelName":"info",
      "msg":"",
      "time":"2019-03-15T21:07:14.058Z",
      "v":1,
      "url":"http://0.0.0.0:4321/",
      "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
      "count":1
   }
]

Desired output:

   {  
      "name":"myLogger",
      "level":30,
      "test":"test123",
      "levelName":"info",
      "msg":"",
      "time":"2019-03-15T21:07:14.058Z",
      "v":1,
      "url":"http://0.0.0.0:4321/",
      "userAgent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
      "count":1
   }

How to reserve error stack

Hi, thanks for your smart browser logger.

I implement simple custom class which call your logger behaviour as below image show.

utils/logger.js

image

But I notice the error stack output which locate to my class instead of real position.

image

If I want to reserve error stack from my logic caller (like my app.js) instead of my custom logger.js, how should I implement it?

Thanks for your time,

regards.

Exclude fields

Hi! My log is getting quite cluttered. Is there a way to exclude fields?

Like v, count, time?

I read this discussion (trentm/node-bunyan#52) about excluding fields for bunyan, but I wasn't successful for browser-bunyan. Some help would be appreciated. Thanks so much.

Double server records

I have an issue with @browser-bunyan/server-stream
if server return an error, the failed log message never send, but next request doubled
steps to reproduce:

  • stop api server
  • logger.fatal( "1" );
  • start api server
  • logger.fatal( "2" ); // 2 requests with msg: "1" is sent, but should be "1" and "2"
  • logger.fatal( "3" ); // 2 requests with msg: "3" is sent, but should be only one message

config:

const logger = createLogger({
  name: 'serverLogger',
  streams: [{
    level: WARN,
    stream: new ServerStream({
      url: '/api/v1/logger',
      method: 'POST'
    }),
  }],
});

start and end timer

Do you have plans to support few more features such timer similar to console.time(label);?

ConsoleRawStream. Where do I import it from?

import {  ConsoleRawStream } from 'browser-bunyan'; // compilation error in 1.6.2

It is exported and inlined in the all the JS-file inside the brower-bunyan package, but it's types are not exported it in the TypeScript definition.

This happened when bumping from 1.5.3 to 1.6.2.

The documentation might suggest that I should import from @browser-bunyan/console-raw-stream instead, but since it's already inlined in browser-bunyan doesn't that lead to duplicate code in my bundle?

Can we return result of executing "write" methods of streams?

I want to create SentryStream and this stream will send fatal errors to sentry.
Sentry has the ability to return issue id - I want somehow to get this ID.


Could we just return an array of results of executing write methods?
Like this #67


Will work like this:

export class SentryStream {
    write(rec) {
        // send error to Sentry
        const id = "...." // some Sentry Issue ID
        return id;
    }
}

const result = logger.fatal(new Error('some error'));
console.log(result); // ["...sentry-issue-id..."] 

File and Line number is reported as coming from bunyan instead of location of log.

I'm using browser bunyan and I've configured it to log the source file and line number, but it is reporting file and line in bunyan.

Initialized:

$provide.decorator('$log', function($delegate) {
      $delegate = bunyan.createLogger({
        name: 'tracer-logger',
        src: true,
        streams: [{
          level: 'info',
          stream: new bunyan.ConsoleFormattedStream(),
          type: 'raw'
        }]
      });
      return $delegate;
    });

Console log:
[20:01:30:0512] INFO: tracer-logger: Websocket batch update [23]. browser-bunyan.min.js:6

https://www.evernote.com/l/AAIdfssu8jtKRJlPsailB1hqB82VVadfzGM

What am I doing wrong?

Document childName field

When creating a child logger a childName field can be passed and utilized by console-formatted-stream,

This appears to be undocumented.

I was in the process of creating my own version of console-formatted-stream when I discovered this.

Can't Import ServerStream

Hello,

When I try to import { ServerStream } from '@browser-bunyan/server-stream'; , I get an error saying "Error: Cannot find module '@browser-bunyan/server-stream'"

Color cannot support

I apply your default css by using new ConsoleFormattedStream while notice that some color cannot support, all format display failed.

image

And how should I fix it?

Thanks for your time.

No option for flushOnNavigate

We have a requirement that we'd like to have the logs sent back to the server when a user changes pages. It looks like the library supports dumping the logs when the user closes the tab or window via the unload event, and we'd like to add in the option to dump them via the beforeunload event as well.

We are fine to make the change, however we have a lengthy review process we have to go through in order to contribute to open source projects. So before we go through that process we'd like to verify that A) this isn't already being worked on and B) this is a change that would be a welcome addition to the library.

Rebase on top of bunyan

Any suggestion for how to rebase this on top of bunyan master? I thought there's would be a fork reference between the github repos but that does not appear to be the case.

Maintenance status and divergence from (server-side) bunyan

Hey @philmander,

Looks like there has been additional divergence and bug fixes between bunyan and browser-bunyan since #4 last year.

Are there any plans to bring in changes from bunyan? Wondering if this npm module is maintained/safe to use, or whether I should just accept a bit of bloat from a browersfied bunyan and excerpt ConsoleFormattedStream from brower-bunyan (failed because of divergence between browersfied bunyan and browser-bunyan).

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.