GithubHelp home page GithubHelp logo

mono0926 / simple_logger Goto Github PK

View Code? Open in Web Editor NEW
57.0 4.0 9.0 86 KB

Provides super simple APIs for logging. The log also includes caller info by setting includeCallerInfo to true. On Android Studio, jump to caller info by clicking the log.

Home Page: https://pub.dartlang.org/packages/simple_logger

License: MIT License

Dart 100.00%
logger logging dart caller caller-info log-level simple customizable

simple_logger's Introduction

simple_logger

Provides super simple APIs for logging. The log also includes caller info by setting includeCallerInfo to true. On Android Studio, jump to caller info by clicking the log.

Usage

// Singleton (factory)
final logger = SimpleLogger();

// Printed without called location
logger.info('Hello info!');
// -> 👻 INFO  2018-12-16 21:46:20.092695 [caller info not available] Hello info!

// Printed function which returns object
logger.info(() => 'Hello info!');
// -> 👻 INFO  2018-12-16 21:46:20.092695 [caller info not available] Hello info!

logger.setLevel(Level.WARNING);

// Not printed
logger.info('Hello info!');

// Printed
logger.warning('Hello warning!');
// -> ⚠️ WARNING  2018-12-16 21:46:20.101114 [caller info not available] Hello warning!

logger.shout('Hello shout!');
// -> 😡 SHOUT  2018-12-16 21:46:20.101308 [caller info not available] Hello shout!

logger.setLevel(
  Level.INFO,
  // Includes  caller info, but this is expensive.
  includeCallerInfo: true,
);

// Printed with called location
logger.info('Hello info!');
// -> 👻 INFO  2018-12-16 21:50:03.562583 [example/simple_logger_example.dart 29:10 in main] Hello info!

// Customize level prefix
logger.levelPrefixes = {};
logger.info('Hello info!');
// -> INFO  2018-12-16 21:50:03.562583 [example/simple_logger_example.dart 29:10 in main] Hello info!

logger.formatter = (info) => 'Customized output: (${info.message})';
logger.info('Hello info!');
// -> Customized output: (Hello info!)

logger.onLogged = (info) => print('Insert your logic with $info');
logger.info('Hello info!');
// -> Customized output: (Hello info!)
// -> Insert your logic with Instance of 'LogInfo'

Technical Articles

Features and bugs

Please file feature requests and bugs at the issue tracker.

simple_logger's People

Contributors

honishi avatar mono0926 avatar riscait avatar sgr-ksmt avatar sh-ogawa 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

Watchers

 avatar  avatar  avatar  avatar

simple_logger's Issues

Unable to determine the log caller in flutter web release/profile mode

Thank you for the informative package.

I don't think it is a simple_logger issue, but when I run Flutter Web in Profile mode, I can't identify the part of the source that is outputting the logs.

In debug mode, the source can be identified without problems.
Is this because I can't get a stack trace in Profile mode?

flutter run -d chrome --profile

image

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:simple_logger/simple_logger.dart';

final logger = SimpleLogger()
  ..setLevel(
    kReleaseMode ? Level.OFF : Level.ALL,
    includeCallerInfo: !kReleaseMode,
  );

void main() {
  logger.severe('severe');

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    logger.info('info');

    return const MaterialApp(
      title: 'Flutter Demo',
      home: Scaffold(),
    );
  }
}

Too long string

When the printed string is too long, it cannot be printed later

I hope it can be solved

Tags feature

I want SimpleLogger to set any tags to a log and filter specific tags that be should show.

Cannot show log in isolate.spawn

Has init before,test code:

void testIsolate(){
SimpleLogger().fine('thread 21');
Isolate.spawn(otherFunc,23);
sleep(Duration(seconds: 2));
SimpleLogger().fine('thread 22');
}

static void otherFunc(int count) {
print("23");
SimpleLogger().fine('thread 23');
logger.fine("other $count");
}
please see the image:
image

关于日志无法输出过长内容的处理

首先非常感谢您做出这么好用的插件库造福世界。

在开发中,如果打印的字符过长会导致无法完全展示,希望可以新版本中进行处理来达到可以完全展示内容的目的(可以对过长字符进行分割并多次打印。)

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.