Skip to content

Commit

Permalink
defaults logs like component
Browse files Browse the repository at this point in the history
  • Loading branch information
twocolors committed Mar 27, 2023
1 parent 5364c13 commit 97d7018
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ const connection = new Connection({
- `async getTimeService()` - subsribes to entities state changes. Returns time object
- `async listEntitiesService()` - subsribes to entities state changes. Returns entities list
- `subscribeStatesService()` - subsribes to entities state changes
- `subscribeLogsService(level = 3, dumpConfig = false)` - subsribes to logs.
- `subscribeLogsService(level = 5, dumpConfig = false)` - subsribes to logs.
- `level` - logs level. 0 - NONE, 1 - ERROR, 2 - WARN, 3 - INFO, 4 - DEBUG, 5 - DEBUG, 6 - VERBOSE, 7 - VERY_VERBOSE
- `dumpConfig`
- `cameraImageService(single = true, stream = false)` - requests camera image.
Expand Down
5 changes: 3 additions & 2 deletions lib/connection.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const { serialize, deserialize, pb } = require('./utils/messages');
const Package = require('../package.json');

// https://github.com/miguelmota/is-base64/blob/master/is-base64.js#L17
const isBase64 = (payload) => (new RegExp('^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\/]{3}=)?$', 'gi')).test(payload)
const base64Regex = /^(?:[A-Za-z0-9+\\/]{4})*(?:[A-Za-z0-9+\\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/;
const isBase64 = (payload) => new RegExp(base64Regex, 'gi').test(payload);

const base64Decode = (message) =>
isBase64(message) ? Buffer.from(message, 'base64').toString('ascii') : message;
Expand Down Expand Up @@ -280,7 +281,7 @@ class EsphomeNativeApiConnection extends EventEmitter {
if (!this.authorized) throw new Error(`Not authorized`);
this.sendMessage(new pb.SubscribeStatesRequest());
}
subscribeLogsService(level = pb.LogLevel.LOG_LEVEL_INFO, dumpConfig = false) {
subscribeLogsService(level = pb.LogLevel.LOG_LEVEL_DEBUG, dumpConfig = false) {
if (!this.connected) throw new Error(`Not connected`);
if (!this.authorized) throw new Error(`Not authorized`);
const message = new pb.SubscribeLogsRequest();
Expand Down

0 comments on commit 97d7018

Please sign in to comment.