mowispace / react-native-logs

Performance-aware simple logger for React-Native and Expo with namespaces, custom levels and custom transports (colored console, file writing, etc.)
MIT License
467 stars 33 forks source link

Failed to display colour in console #37

Closed briantical closed 3 years ago

briantical commented 3 years ago

Hello, I am using the default example. I have also reviewed some of the previous issues about displaying colour though I have failed to view the logs in the console in colour. I am also using typescript in my project.

Below is the implementation

import { logger, consoleTransport } from "react-native-logs";

const defaultConfig = {
  severity: "debug",
  transport: consoleTransport,
  transportOptions: {
    color: "ansi", // custom option that color consoleTransport logs
  },
  levels: {
    debug: 0,
    info: 1,
    warn: 2,
    error: 3,
  },
  async: true,
  dateFormat: "time",
  printLevel: true,
  printDate: true,
  enabled: true,
};

var log = logger.createLogger(defaultConfig);
alessandro-bottamedi commented 3 years ago

Hi, which console do you use? for the chrome console try to change the transportOptions.color option:

import { logger, consoleTransport } from "react-native-logs";

const defaultConfig = {
  transportOptions: {
    colors: "web" // or "ansi",
  },
};

var log = logger.createLogger(defaultConfig);
briantical commented 3 years ago

I am using terminal

alessandro-bottamedi commented 3 years ago

I've tested with terminal (MacOS X Catalina) and I can see all colors without problems with the "ansi" option. What kind of console do you have on terminal, ZSH?

briantical commented 3 years ago

Yes, i am using zsh

alessandro-bottamedi commented 3 years ago

Does anyone else experience the same problem?

sunilloharshoreline1 commented 3 years ago

I m facing the same issue. I m using Terminal (Version 2.11 (440)) on Mac Big Sur 11.4 Beta. i tried web and ansi but couldn't see the color.

sunilloharshoreline1 commented 3 years ago

one thing I found is the key name is colors not the color . when I use ansi, i could see the color, web doesnt seem to work: transportOptions: { colors: "ansi" }

alessandro-bottamedi commented 3 years ago

Sorry, there was an error in the documentation, the right option is colors, set it to web for chrome and ansi for the terminal. Let me know if the problem persists and I will reopen the issue.