Skip to content

Commit 61daea1

Browse files
authored
V2.0.x (#8)
* changed path to dist * removes Angular animation and forms * updated to Angular 8.3.29 for compiler * removes tsickle * updated to Angular 9.1.12 * upgraded to Angular 10 * fixes unit tests * audit fixes * updated * restructures the project * drops support to tapping observables * updated tests * updated readme * updated
1 parent 94c53ed commit 61daea1

38 files changed

+8809
-9043
lines changed

.browserslistrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# You can see what browsers were selected by your queries by running:
6+
# npx browserslist
7+
8+
> 0.5%
9+
last 2 versions
10+
Firefox ESR
11+
not dead
12+
not IE 9-11 # For IE 9-11 support, remove 'not'.

.travis.yml

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,24 @@ node_js:
77

88
branches:
99
only:
10-
- master
10+
- develop
1111
- /^v\d+\.\d+(\.\d+)?(-\S*)?$/
1212

1313
cache:
1414
directories:
1515
- node_modules
1616

17-
# Set DISPLAY for Xvfb
18-
env:
19-
- DISPLAY=:99.0
17+
services:
18+
- xvfb
2019

21-
# Use APT Addon to install Chrome
2220
addons:
23-
apt:
24-
sources:
25-
- google-chrome
26-
packages:
27-
- google-chrome-stable
28-
29-
before_install:
30-
- sh -e /etc/init.d/xvfb start
21+
chrome: stable
3122

3223
install:
24+
- npm set progress=false
3325
- npm install
3426
- npm install coveralls
3527

3628
script:
3729
- npm test
38-
- cat ./coverage/logger/lcov.info | ./node_modules/coveralls/bin/coveralls.js
30+
- cat ./coverage/reactgular/logger/lcov.info | ./node_modules/coveralls/bin/coveralls.js

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# 2.0.0
2+
3+
This release focuses on Angular compatibility and security patches for npm packages.
4+
5+
## Changes
6+
* This release targets Angular 10 and above.
7+
8+
## Breaking Changes
9+
* Drops support for tapping observables.
10+
11+
# 1.0.3
12+
13+
* This release targets Angular 8 and above.
14+
15+
# 1.0.2
16+
17+
* Skip this release.
18+
19+
# 1.0.0
20+
21+
* First release.

README.md

Lines changed: 13 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
[![Build Status](https://travis-ci.org/reactgular/logger.svg?branch=master)](https://travis-ci.org/reactgular/logger)
2-
[![Coverage Status](https://coveralls.io/repos/github/reactgular/logger/badge.svg?branch=master)](https://coveralls.io/github/reactgular/logger?branch=master)
1+
[![Build Status](https://travis-ci.org/reactgular/logger.svg?branch=develop)](https://travis-ci.org/reactgular/logger)
2+
[![Coverage Status](https://coveralls.io/repos/github/reactgular/logger/badge.svg?branch=develop)](https://coveralls.io/github/reactgular/logger?branch=develop)
33
[![npm version](https://badge.fury.io/js/%40reactgular%2Flogger.svg)](https://badge.fury.io/js/%40reactgular%2Flogger)
44

55
## What is Logger?
66

7-
Logger is a small Angular service that writes output to the browser's console. It helps make
7+
Logger is a small Angular service for writing output to the browser's console. It helps make
88
console messages easier to filter by prefixing messages with the current class name. So if you have a component named `MainComponent` you
9-
can filter by `Main:` and see only console messages from that component. It also supports tapping *observables* so you can see how
10-
data is flowing through your application.
9+
can filter by `Main:` and see only console messages from that component.
1110

1211
> Logger extends console so messages continue to display the current *filename* and *line number*.
1312
@@ -27,13 +26,6 @@ export class MainComponent implements OnInit {
2726
public ngOnInit() {
2827
this._log.debug('Hello world!');
2928
// ^^^ outputs "Main: Hello world!"
30-
31-
this._subject.pipe(
32-
this._log.tap().debug('Hello world!')
33-
).subscribe();
34-
35-
this._subject.next("Everyone!");
36-
// ^^^ outputs "Main$ Hello world! Everyone!"
3729
}
3830
}
3931
```
@@ -55,18 +47,13 @@ export class MainComponent implements OnInit {
5547
* [LogService.warn()](#logservicewarn)
5648
* [LogService.getPrefix()](#logservicegetprefix)
5749
* [LogService.setPrefix()](#logservicesetprefix)
58-
* [LogService.tap()](#logservicetap)
5950
* [LogService.withPrefix()](#logservicewithprefix)
60-
- [TapperMethods](#tappermethods)
61-
* [TapperMethods.debug/error/info/log/warn()](#tappermethodsdebugerrorinfologwarn)
62-
* [TapperMethods.pipe()](#tappermethodspipe)
63-
* [TapperMethods.logger()](#tappermethodslogger)
6451

6552
## Why another console logger for Angular?
6653

6754
I've been copying and pasting the same log service between projects for several years. Everything else I tried
6855
was either too complicated or *erased* the *file name* and *line number* from the browser's console output, and I just kept reusing my trusty
69-
logger code. I decided it was time to make it an official library that could be easily installed and reused.
56+
logger code. I decided it was time to make it a library that could be easily installed and reused.
7057

7158
### Simple
7259

@@ -91,18 +78,15 @@ export class MainComponent {
9178
}
9279
```
9380

94-
The prefix value can be anything that you want, but using `MainComponent.name` means that the value is
81+
The prefix value can be anything that you want, but using `MainComponent.name` means that the value will be
9582
updated if you rename the class using an IDE that automatically updates all usages.
9683

9784
## Installation
9885

99-
To get started, install the package from npm. The latest version (1.x) supports Angular 8.
86+
To get started, install the package from npm.
10087

10188
```bash
102-
npm install --save @reactgular/logger
103-
104-
# or if you are using yarn
105-
yarn add @reactgular/logger
89+
npm install @reactgular/logger
10690
```
10791

10892
then in `app.module.ts`, import the `LoggerModule`:
@@ -123,9 +107,9 @@ When you include the module in the import, you can pass a configuration object o
123107
If you are lazy loading, you can just use the `LoggerModule` module.
124108

125109
Options such as `enabled` can be passed to the module as the second argument in the `forRoot` method. When `enabled` is
126-
set to *false* the log service is replaced with a tiny *proxy* service that outputs nothing.
110+
set to *false* the log service gets replaced with a tiny *proxy* service and outputs nothing.
127111

128-
It's important that you add `LoggerModule.forRoot()` at the root of your modules.
112+
It's important for you add `LoggerModule.forRoot()` at the root of your modules.
129113

130114
## LoggerConfig
131115

@@ -158,7 +142,7 @@ constructor(log: LogService) {
158142

159143
## LogService Prefixes
160144

161-
When you're using the `LogService` with Angular classes like components, services, pipes and etc. The name of those classes can be used to set the
145+
When you're using the `LogService` with Angular classes like components, services, pipes, etc. The name of those classes can be used to set the
162146
prefix string for each log message to the console. Using a prefix value of `"MainComponent"` can create *wide* console messages. So this function
163147
creates a new `LogService` object with a *trimmed* prefix where the *tail* strings have been removed.
164148

@@ -176,8 +160,8 @@ export class MainComponent {
176160
}
177161
```
178162

179-
When *tail* strings are removed is configured in the `LoggerConfig` you used when calling `LoggerModule.forRoot()`. If you don't define an
180-
array of strings for `tails: string[]` then these default values are used.
163+
When you set the `tails` option in the `LoggerConfig` it replaces all the tails that are removed from prefixes. If you don't define an
164+
array of strings to `fails` then these default values will be used.
181165

182166
```typescript
183167
/**
@@ -194,7 +178,6 @@ import {LoggerModule, LOGGER_TRAILS_DEFAULT} from '@reactgular/logger';
194178
@NgModule({
195179
imports: [
196180
LoggerModule.forRoot({
197-
enabled: !environment.production,
198181
tails: [...LOGGER_TAILS_DEFAULT, 'FooBar', 'Magic', 'Proxy']
199182
})
200183
]
@@ -242,62 +225,6 @@ Returns the prefix string used by the `LogService` object.
242225
Sets a new prefix for the logger. This will change the *internal* prefix value used by the `LogService`. This function does not have the same
243226
effect as `withPrefix()` which returns a new `LogService` object with a trail strings removed for the prefix.
244227

245-
### LogService.tap()
246-
247-
Creates an observable tapper that can listen for emitted values and output them to the browser's console. See [TapperMethods](#tappermethods) for more information.
248-
249228
### LogService.withPrefix()
250229

251230
Creates a new `LogService` object with the given prefix.
252-
253-
## TapperMethods
254-
255-
Create a `TapperMethods` object by calling `LogService.tap()` inside the `pipe()` of an observable. A tapper subscribes to an outer observable,
256-
and creates a new inner observable that will only emit values to the browser's console. You can apply observable operators to this inner observable
257-
via the [pipe()](#tappermethodspipe) and they will have no side effects on the outer observable.
258-
259-
For example, you can filter values:
260-
261-
```typescript
262-
of(1,2,3,4,5).pipe(
263-
logService.tap().pipe(filter(x => x === 3)).log()
264-
).subscribe();
265-
// prints "3" the console
266-
```
267-
268-
The above applies a `filter()` operator to the tapper observable, but this filter has no side effects on the
269-
original observable. Only output to the console is filter.
270-
271-
### TapperMethods.debug/error/info/log/warn()
272-
273-
The `TapperMethods` object has the same console methods as the `LogService`. The difference is that the tapper logging methods return an
274-
observable operator. That means that the tapper logging methods have to be used inside an `observable.pipe()` method.
275-
276-
For example:
277-
278-
```typescript
279-
of(1,2,3,4).pipe(
280-
logService.tap().log()
281-
).subscribe();
282-
```
283-
284-
Because the tapper has to create an operator function the browser's console can not report the correct file name and line number. You
285-
can use the `LogService` with a regular `tap()` operator if you need the file name, but you loose the ability to filter or map values
286-
before they are printed to the console.
287-
288-
For example:
289-
290-
```typescript
291-
of(1,2,3,4,5).pipe(
292-
tap(val => logService.log(val))
293-
).subscribe()
294-
```
295-
296-
### TapperMethods.pipe()
297-
298-
Adds observable operators to the inner observable that is tapping into the outer observables. Operators added to the
299-
tapper will have no effect on the outer observable, but will be applied to the output for the console.
300-
301-
### TapperMethods.logger()
302-
303-
Returns the inner `LogService` used by the tapper for logging to the console.

angular.json

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"newProjectRoot": "projects",
55
"projects": {
66
"logger": {
7-
"root": "library/logger",
8-
"sourceRoot": "library/logger/src",
7+
"root": "projects/reactgular/logger",
8+
"sourceRoot": "projects/reactgular/logger/src",
99
"projectType": "library",
1010
"prefix": "rg",
1111
"schematics": {
1212
"@schematics/angular:component": {
13-
"styleext": "scss",
13+
"style": "scss",
1414
"changeDetection": "OnPush",
1515
"flat": false
1616
},
@@ -28,24 +28,29 @@
2828
"build": {
2929
"builder": "@angular-devkit/build-ng-packagr:build",
3030
"options": {
31-
"tsConfig": "library/tsconfig.lib.json",
32-
"project": "library/ng-package.json"
31+
"tsConfig": "projects/reactgular/logger/tsconfig.lib.json",
32+
"project": "projects/reactgular/logger/ng-package.json"
33+
},
34+
"configurations": {
35+
"production": {
36+
"tsConfig": "projects/reactgular/logger/tsconfig.lib.prod.json"
37+
}
3338
}
3439
},
3540
"test": {
3641
"builder": "@angular-devkit/build-angular:karma",
3742
"options": {
38-
"main": "library/logger/test.ts",
39-
"tsConfig": "library/tsconfig.spec.json",
40-
"karmaConfig": "library/karma.conf.js"
43+
"main": "projects/reactgular/logger/test/test.ts",
44+
"tsConfig": "projects/reactgular/logger/tsconfig.spec.json",
45+
"karmaConfig": "projects/reactgular/logger/karma.conf.js"
4146
}
4247
},
4348
"lint": {
4449
"builder": "@angular-devkit/build-angular:tslint",
4550
"options": {
4651
"tsConfig": [
47-
"library/tsconfig.lib.json",
48-
"library/tsconfig.spec.json"
52+
"projects/reactgular/logger/tsconfig.lib.json",
53+
"projects/reactgular/logger/tsconfig.spec.json"
4954
],
5055
"exclude": [
5156
"**/node_modules/**"

library/logger/public-api.ts

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)