
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Brolog is Logger for Angular in Browser like Npmlog.
<script src='//unpkg.com/brolog'></script>
)log.verbose('Brolog', 'Hello, %s', 'world!'')
)We enabled this in Chrome DevTools via blackboxing a bit ago.What I really get frustrated by is that I cannot wrap console.* and preserve line numbers
Brolog implementes Loggable:
interface Loggable {
error (moduleName: string, message: string, ...args: any[]): void
warn (moduleName: string, message: string, ...args: any[]): void
info (moduleName: string, message: string, ...args: any[]): void
verbose (moduleName: string, message: string, ...args: any[]): void
silly (moduleName: string, message: string, ...args: any[]): void
}
You can import and use it by:
import { Loggable } from 'brolog'
Here's two example:
You can enable Brolog in your page by simple add the following script
tag.
<script src="//unpkg.com/brolog"></script>
<html>
<head>
<script src="//unpkg.com/brolog"></script>
</head>
<body>
<h1>Brolog in Browser Demo</h1>
<script>
var log = Brolog.instance('verbose')
log.info('Test', '123 info message')
log.verbose('Test', '123 verbose message')
log.silly('Test', '123 silly message(should not appear)')
</script>
</body>
</html>
Link: Brolog Live demo
Brolog
is written mainly for act as a logger with Angular. Here's how to Inject Brolog in Angular.
$ npm install brolog --save
...
System.config({
map: {
brolog: 'node_modules/brolog/bundles/brolog.js'
}
})
import { Brolog } from 'brolog'
providers: [
Brolog,
]
class LogApp {
constructor(
private log: Brolog
) {}
}
class LogApp {
testLog() {
this.log.verbose('Brolog', 'test log:%s', 123)
// this will log to browser console
}
}
More details, please see the brolog-angular-demo
git repository at here.
Link: Brolog ♥ Angular Live demo
Get a out-of-the-box log
instance to use it directly.
import { log } from 'brolog'
If fhe environment variable BROLOG_LEVEL
is set, that will be used to set log.level() for the global Brolog instance log
.
import { Brolog } from 'brolog'
const log = new Brolog()
// additional stuff ---------------------------+
// message ----------+ |
// prefix ----+ | |
// level -+ | | |
// v v v v
log.info('fyi', 'I have a kitty cat: %j', myKittyCat)
The level to display logs at. Any logs at or above this level will be
displayed. The special level silent
will prevent anything from being
displayed ever.
level
{String} The level to emit the message atprefix
{String} A string prefix. Set to "" to skip.message...
Arguments to util.format
Emit a log message at the specified level.
For example,
BROLOG_PREFIX
Example:
Shell
BROLOG_PREFIX="(Contact|Puppet)" node wechaty.js
This will equals to set by code API:
log.prefix(/^(Contact|Puppet)$/)
Brolog comes with well test suit to ensure the behavior is expected.
$ npm run unit
...
Unite Test Suite: link
$ npm run e2e
...
End to End Test Suite: link
P.S. running E2E test is based on brolog demo project: git repository
Loggable
interfacerollup
behavior change. (#69)BROLOG_PREFIX
to set the prefix
filter of global log
instance.BROLOG_PREFIX
to set the prefix
filter of global log
instance.brolog@next
when the minor version in SemVer is odd(development release).BROLOG_LEVEL
to set the loglevel of global log
instance.BROLOG_LEVEL
to set the loglevel of global log
instance.Brolog.enableLogging()
method for:
false
for disable loggingtrue
for enable loggingprintTextFunc: (text: string)
for enable logging to a function.Compatible with AOT & WebPack with Angular v4
enableLogging()
to get/set loggerscript
tagFAQs
Npmlog like logger for Browser
The npm package brolog receives a total of 810 weekly downloads. As such, brolog popularity was classified as not popular.
We found that brolog demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.